Process tuple contents on the fly

Barrett Lewis musikal.fusion at gmail.com
Mon Apr 15 15:05:04 EDT 2013


>   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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130415/3641cd11/attachment.html>


More information about the Python-list mailing list