I find myself often doing the following sort of thing (sorry for
lack of whitespace, I don't want the line to break):
for entry, index in map(lambda e,i:(e,i),aList ,range(len(aLis t)):
# ...
This definitely seems like a roundabout way to loop through
parallel lists together. Is this map routine truly the easiest/
best/most straight-forward way to do a for loop through parallel
lists, if I feel that the Python anti-idom of:
for index in range(len(myLis t)):
entry = aList(index)
anotherEntry = anotherList(ind ex)
# ...
???
This also brings up a similar problem for me when iterating over
dictionaries:
for key in myDict:
value = myDict[key]
# ...
This seems a pretty sloppy way to go about it, imo. There must
be something more in the Python spirit! :)
Thanks.
-tom!
Comment