list of tuples with dynamic change in position

Gerard Flanagan grflanagan at gmail.com
Mon Sep 6 11:40:17 EDT 2010


sajuptpm wrote:
> I have a list of tuples l = [(('s','a'),(5,9)), (('u','w'),(9,2)),
> (('y','x'),(3,0))] and postion of values in the tuple change
> dynamicaly. I need a way to access correct value even if change in
> position.

from itertools import starmap, izip, imap
list(imap(dict, starmap(izip, d)))
[{'a': 9, 's': 5}, {'u': 9, 'w': 2}]




More information about the Python-list mailing list