converting tuple to list
Fredrik Lundh
fredrik at pythonware.com
Thu Jan 13 09:14:59 EST 2000
More information about the Python-list mailing list
Thu Jan 13 09:14:59 EST 2000
- Previous message (by thread): converting tuple to list
- Next message (by thread): converting tuple to list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Adrian Eyre <a.eyre at optichrome.com> wrote: > Just out of interest: what is the canonical way of converting a list > of tuples to a dictionary? i.e. the opposite of dict.items() > > [("key1","value1"),("key2","value2")] -> {"key1":"value1","key2":"value2"} I doubt you can do much better than: mydict = {} for k, v in mylist: mydict[k] = v </F> <!-- (the eff-bot guide to) python patterns and idioms: http://www.pythonware.com/people/fredrik/patternbook.htm -->
- Previous message (by thread): converting tuple to list
- Next message (by thread): converting tuple to list
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list