[Python-Dev] chained assignment weirdity

Serhiy Storchaka storchaka at gmail.com
Tue Nov 6 17:14:38 CET 2012


On 06.11.12 14:01, Nick Coghlan wrote:
> Python, on the other hand, is able to preserve primarily left to right
> evaluation in this case with only the far right hand expression needing
> to be evaluated out of order.

I'm surprised, but it is really so.
 >>> {}[print('foo')] = print('bar')
 bar
 foo
I was expecting "foo" before "bar".
Another counterintuitive (and possible wrong) example:
 >>> {print('foo'): print('bar')}
 bar
 foo
 {None: None}


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /