FAQ Database Discussion Community


Enumerating child windows in python?

python,enumerate
I have dabbled around for a year or so using c++ and decided I would try my hand at python as it has a much easier syntax and will increase productivity while I am still learning (I think!). I am trying to enumerate all child windows from a parent window...

EnumerateChildNodesWithName, Can't seem to Remove nodes

swift,position,nodes,enumerate
I'm trying to remove some nodes from a parent node once they reach a certain x position. The problem I have is that the parent node is changing x position, but the children are not changing x position inside the parent (but are obviously moving with the parent), so when...

Adding first occurrence in a 2D list to another list (Python 3.4.2)

python,python-3.x,for-loop,multidimensional-array,enumerate
This is currently my code: num = 0 sav = [["Name: ", "Josh", "Score", "1"], ["Name", "James", "Score: ", "2"], ["Name: ", "Josh", "Score: ", "2"]] sav2 = [[]*5 for _ in range(len(sav)] name2 = sav[num][1] for i, j in enumerate(sav2): if name2 not in j: sav2.append(sav[num]) num = num+1...

JQ: Enumerate Object Stream

object,stream,enumerate,jq
I've got a pipe full of objects and I am trying to add a accumulating count string to each object in a stream with jq to get the following output {"count":"Num_000"} {"count":"Num_001"} {"count":"Num_002"} {"count":"Num_003"} {"count":"Num_004"} {"count":"Num_005"} {"count":"Num_006"} {"count":"Num_007"} {"count":"Num_008"} {"count":"Num_009"} Something like the following but I'm sure I don't need...

How to index rows in my output

python,csv,enumerate
My CSV file is as following (two rows with semicolon separated values) 01;John;231;this is row one 02;Paul;745;this is row two I want result like this: 01 ============== column 1 and row 1 John ============= Column 2 and row 1 231 ============== column 3 and row 1 this is row one...

using enumerate to iterate over a dictionary of lists to extract information

python,dictionary,enumerate
I got some help earlier today about how to obtain positional information from a dictionary using enumerate(). I will provide the code shortly. However, now that I've found this cool tool, I want to implement it in a different manner to obtain some more information from my dictionary. I have...

Python: Enumeration

python,enumerate
People have said that the enumerate function is a hidden trick in python. I am still unsure as to what it does. The documentation just tells me that it returns an enumerate object. That doesn't exactly help me in understanding this concept. What does enumeration do?...

Python Replace elements in a list that are also in another list, and delete others

python,list,enumerate
I would like to make a replacement on elements of the list l1 that are also in l2, and delete elements that are not in l2. I don't understand why the following solution does not work: it returns [33, 33, 'd'] instead of: [33, 33, '33'] Here is my solution:...

Python: Split list in to sets

python,set,iterable,enumerate
I'm trying to split a list in to enumerated sets and I have a implementation that seems to do what I want but it doesn't feel very "pythonic" is there a better way? The below example splits the item in to sets of maximum size 3 and returns each item...

How can I populate a dictionary with an enumerated list?

python,dictionary,enumerate
I have the following dictionary, where keys are integers and values are floats: foo = {1:0.001,2:2.097,3:1.093,4:5.246} This dictionary has keys 1, 2, 3 and 4. Now, I remove the key '2': foo = {1:0.001,3:1.093,4:5.246} I only have the keys 1, 3 and 4 left. But I want these keys to...

Swift enumerate functions. How does it work behind?

swift,enumerate
The enumerate function returns a tuple for each item in the array composed of the index and the value for that item. The map function returns an array of elements built from the results of applying a provided transforming closure for each element in the array. Declaration: func map<U>(transform:...

Short for 'for i in range(1,len(a)):' in python

python,for-loop,range,iteration,enumerate
In python, is there a short way of writing for i in range(len(l)):? I know I can use for i,_ in enumerate(l):, but I want to know if there's another way (without the _). Please don't say for v in l because I need the indices (for example to compare...

Reading from dictionaries nested in a list

python,list,dictionary,nested,enumerate
I am relatively new to Python so bare with me. [ { "wrong3": "Nope, also wrong", "question": "Example Question 1", "wrong1": "Incorrect answer", "wrong2": "Another wrong one", "answer": "Correct answer" }, { "wrong3": "0", "question": "How many good Matrix movies are there?", "wrong1": "2", "wrong2": "3", "answer": "1" } ]...

Python find index in a string

python,list,enumerate
I am trying to print the index of the word in this string below. The problem right now is that it is checking for each element in the list and returning false. How can I make it return "False" if the word isn't in the list and not check it...

Python: Check whether the list is in sequential or not | End of the list is defined

python,list,hex,sequence,enumerate
My function is something like this, thanks to this answer, which is to check whether all the values of mylist are sequential or not, which is hexadecimal list. For example: mylist1 = ['03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c','0d', '0e', '0f'] mylist2 = ['03', '05', '06', '07',...

Understanding reduce with enumerate for a list of lists

python,list,reduce,enumerate
I am trying to multiply the first number, 1, of the first list, the second number of the second list, 5, and so on for a list of lists. For example, for [[1, 2, 3], [4, 5, 6], [7, 8, 9]], I'd like to get 1*5*9. While there are many...

Missing directory and file info

c#,ienumerable,enumerate,directoryinfo,filesysteminfo
The following is not returning a full list of files and directories: IEnumerable<FileSystemInfo> files = new DirectoryInfo("C:\\Windows\\System32\\drivers").EnumerateFileSystemInfos("*", SearchOption.AllDirectories); The application is run as a administrator. There are no additional file filter drivers in place. For example if I run: foreach (FileSystemInfo file in files) { Console.WriteLine(file.Name); } I get: en-US...

For loop enumerate. Python

python,json,dictionary,nested,enumerate
Right now I have a JSON with a list containing two dictionaries. This code allows the user to search through the list via index number, retrieving a dictionary. Currently I get two printed results one for each dictionary, for example if I typed the index number 1, I get: No...