[issue11205] Evaluation order of dictionary display is different from reference manual.

Ezio Melotti report at bugs.python.org
Tue Dec 25 15:58:49 CET 2012


Ezio Melotti added the comment:

I came across the same problem in #16777.

IMHO the current behavior is better, and the documentation should be fixed instead, for the following reasons:
 1) it's consistent with assignments, where the RHS is evaluated before the LHS (see also msg128500).  This should also be the behavior of the dict(k=v) syntax, and what I personally expect;
 2) changing it back is not backward-compatible with any code written during the last 10 years;
 3) keeping the current behavior and fixing the docs is simpler than fixing the code to match the docs;

In addition, I would avoid writing code with side-effects in a dict literal, even if the order was documented and guaranteed.  The fact that we don't see many reports about this seems to indicate that people don't write such code, or if they do they rely on the current order.

----------
nosy: +ezio.melotti, gvanrossum
type:  -> behavior

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11205>
_______________________________________


More information about the Python-bugs-list mailing list