Dictionary to tuple

bruno modulix onurb at xiludom.gro
Tue Jun 28 11:16:30 EDT 2005


Tim Williams (gmail) wrote:
(snip)
>>>>d =  {1:'one',2:'two',3:'three'}
>>>>t = tuple([(k,v) for k,v in d.iteritems()])

Err... don't you spot any useless code here ?-)

(tip: dict.items() already returns a list of (k,v) tuples...)

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list