How complex is complex?
Vito De Tullio
zak.mc.kraken at libero.it
Fri Mar 20 05:42:04 EDT 2009
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()}
>
> That's a syntax I have not seen in the 2-to-3 difference docs, so I'm not
> familiar with it. How does that cause "a" to be updated?
I think he would write
>>> a = { 'a': 4, 'c': 6, 'b': 5 }
>>> a = { k:v+1 for k, v in a.items() }
>>> a
{'a': 5, 'c': 7, 'b': 6}
--
By ZeD
More information about the Python-list
mailing list