Tim Roberts wrote: > bearophileh...@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 -- http://mail.python.org/mailman/listinfo/python-list