Python: Modifying a List of Elements while Iterating - python-3.x

I have the below list:
list =[5,10,15,20,25,30]
...and I would like to keep the same list but have its elements increased by 5. How could we do this without creating a new list? What kind of loop should I create for this? Is there another way?
Thanks!

If you want to add another list to the existing list you can use extend in-build functions.
please refer below link to know more about that:
[https://www.geeksforgeeks.org/append-extend-python/][1]

Related

How to retrieve invisible elements form list on the page in Xamarin.UITest?

I have a list of 20 elements and when I use app.Query on the page, Xamarin.UITest gives me only 3 elements as only 3 elements are visible in UI. How can I retrieve all 20 elements from the list inside of my UITest?
Try using All() in Query(). Something like:
app.Query(c => c.All().Class("ListElementsClass"))
Where ListElementsClass is the class of the elements you want to search on the list.
https://developer.xamarin.com/api/member/Xamarin.UITest.Queries.AppQuery.All/
If it is a list with scroll you can use the function app.ScrollUp() / app.ScrollDown()... and you can do your checks before each scroll
If you find another way, I would appreciate it.
Try writing a backdoor method to expose whatever information you need (in this case the total count of list items) and then call it via Invoke

Clear collection object or retrieve last item

Is there a clear method to remove all items for a collection object in vba? Like
colObj.clear
because having to loop through entire thing to clear all is ;_;
Alternatively, is there a last item method like colObj.lastitem or do I have to colObj.count to get last item then something like colObj.item(colObj.count-1) to get second to last item?
My search suggests there is no such methods I seek but then again name is no longer documented but it still works. And yes, I already tried .clear XD
Or if anyone knows a better way to close certain open workbooks please offer suggestions.
Edit: perhaps during the for each i in colObj loop of whatever actions I need to take, I can put colObj.remove i at the very end? Essentially deleting items as I go?
There is no Clear method, but to clear the collection you can do this:
Set colObj = New Collection

Orchard CMS - query lists from views

I created a list and added some items to it. From a view ( not related to this list), I am trying to access the items of this list.
I can get the list of items by using the following query :
contentManager.Query<ContentPart>("myContentTypeName")
This gives me a list.
But, consider this scenario -
-> I create an myContentTypeName and add it to a list.
-> I create another Item but didn't add it to any list.
The above query returns ALL the items of that type. How can I filter this query and get only the items that are a part of the list?
Thanks!
If you are using >= 1.4 version of Orchard, use the projector module. Starting with 1.4 List is pretty much deprecated. If you still need to use the List, I think what you want to do is query for the List content items, not the items within it.

How to change ElementTree attribute keys?

I want to change the attributes of an existing element, and not just the values, but add/remove/change the keys too. For example,
<frame_geometry name="border" has_title="false"/>
I would like to add: rounded_top_left="5" etc...
Is modifying element attributes' keys after creation possible?
If not, perhaps I could use a workaround, something like storing all the element's attributes in a temporary dictionary and then creating a new element from that +/- any desired changes?
This solution is not desirable however because the elements I need to modify have several subelements also...
I figured it out. So simple.
Add new attribute:
element.attrib['newkey'] = 'newvalue'
will add an attribute to existing element.
To remove an existing attribute:
del element.attrib['unwanted_key']
As far as modifying existing keys, I still don't know if that's possible, but with add/remove you can easily work around.
I've had success by iterating through the elements I was hoping for a .rename style function
For element in XMLData:
if element.tag = Searching:
element.tag = "NewTag"
#Now its element.NewTag

Why the OnWorkflowItemChanged is different between List and document library?

I am doing a workflow for a document library. I put a OnWorkflowItemChanged, and I want to get the value of the column which is changed. I use the workflowProperties.Item["name"] and use the afterProperties. But when I use the workflowProperties.Item["column name"], I still got the original value. When I use the afterProperties, it's NULL.
Then I make another workflow that is the same as above for a list. I can use the workflowProperties.Item["column name"] to get the new value in OnWorkflowItemChanged.
Has anyone come across this problem before? Can you give me some help?
The question seems to mix up Item with ExtendedProperties. As to why a difference is seen on a List/Document Lib, it might have something to do with versionining or perhaps the internal serialization is different. Anyway, some of my experience is outline below. I hope it may be of use:
Use the GUID (as a Guid object, not a string) to access the Before / After ExtendedProperties field. Using the Display Name in the ExtendedProperties will not work. The documentation on it is wrong. You can use SPList.Fields to go from Display Name to Column ID (Guid).
I bind all "Before" to MyWhatever_PreviousProperties and all "After" to MyWhatever_Properties, only accessing MyWhatever_[Previous]Properties after the appropriate event(s)).

Resources