How complex is complex?

R. David Murray rdmurray at bitdance.com
Sat Mar 21 07:41:51 CET 2009


Terry Reedy <tjreedy at udel.edu> wrote:
> Vito De Tullio wrote:
> > Tim Roberts wrote:
> > 
> >> bearophileHUGS at lycos.com wrote:
> >>> In Python 3 those lines become shorter:
> >>>
> >>> for k, v in a.items():
> >>> {k: v+1 for k, v in a.items()}
> 
> This is nonsensical.  It creates and discards a complete new dict for 
> each item in the original dict.  The reuse of names 'k' and 'v' in the 
> comprehension just confuse.

You have to look back at the original post in which those
lines appeared, and then look back further at the post which
they were commenting on.  Those two lines do not constitute
consecutive lines of code, they are individual replacements
for individual lines in two different previous examples, one
of which updates the dict in place and the other of which
creates a new dict.

I think bearophile left out too much context :)

--
R. David Murray           http://www.bitdance.com




More information about the Python-list mailing list