The dict display is considered an *expression* and thus must follow the L2R rule. The assignment is explicitly covered by the R2L rule for assignments (only). Weird or not, those are the rules, and I don't want to change them.
On Wed, Nov 7, 2012 at 1:39 PM, Ned Batchelder <n...@nedbatchelder.com> wrote: > > On 11/7/2012 12:08 PM, Serhiy Storchaka wrote: > > On 07.11.12 17:12, Nick Coghlan wrote: > > Since you've indicated the implementation is in the wrong here and you > also want to preserve opcode semantics, I think Skip's patch is > correct, but also needs to be applied to dict comprehensions (now we > have them). The extra bytecode is only ROT_TWO, which is one of the > cheapest we have kicking around :) > > > Not only to dict comprehensions, but also to item assignments. It will be > weird if a dict comprehension and a plain loop will be inconsistent. > > > Just to be clear: the reference guide says that the behavior *SHOULD BE* > (but is not yet) this: > > Python 3.3.0 >>>> {print("a"):print("b")} > a > b > {None: None} >>>> d = {} >>>> d[print("a")] = print("b") > b > a >>>> > > Is this or is this not "weird" to you? > > --Ned. > > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/ned%40nedbatchelder.com > > > > _______________________________________________ > Python-Dev mailing list > Python-Dev@python.org > http://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: > http://mail.python.org/mailman/options/python-dev/guido%40python.org > -- --Guido van Rossum (python.org/~guido) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com