On 15/04/2013 20:05, Barrett Lewis wrote:



       d = {}
       for key, d[key] in (("this",18), ("that",17), ("other",38)):
         print key
         do_something(d)


Why not use a dict comprehension?
d = {k:v for k,v in  (("this",18), ("that",17), ("other",38))}

I feel this is more straightforward and easier to read. the results are
the same however.

Why use a dict comprehension? :-)

d = dict((("this",18), ("that",17), ("other",38))}

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to