[Python-bugs-list] [ python-Bugs-448679 ] Left to right

noreply@sourceforge.net noreply@sourceforge.net
Tue, 26 Nov 2002 14:56:18 -0800


Bugs item #448679, was opened at 2001-08-07 06:55
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=448679&group_id=5470

Category: Documentation
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tim Peters (tim_one)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: Left to right

Initial Comment:
The Ref Man doesn't explicitly say anything about 
Python's left-to-right evaluation order.  Strict left-
to-right was Guido's intent, though, and it comes up a 
few times per year on c.l.py (indeed, I was just 
replying to a msg asking about it).

The docs should get fleshed out.

There's also a bug:

>>> counter = 0
>>> def i():
...     global counter
...     counter += 1
...     return counter
...
>>> {i(): i()}
{2: 1}
>>> {i(): i(), i(): i()}
{4: 3, 6: 5}
>>>

That is, key:value *pairs* are evaluated left to 
right, but within a single key:value pair, the value 
gets evaluated first.  When I asked Guido about that 
some years ago, he agreed it was a bug.


----------------------------------------------------------------------

>Comment By: Gustavo Niemeyer (niemeyer)
Date: 2002-11-26 22:56

Message:
Logged In: YES 
user_id=7887

I'm attaching a suggested solution for the problem,
including documentation and reordering of dict evaluation.


----------------------------------------------------------------------

Comment By: Martin v. L÷wis (loewis)
Date: 2002-08-04 09:58

Message:
Logged In: YES 
user_id=21627

With the patch attached, this behaviour is cast into stone
(or, atleast into a SF tracker :)

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=448679&group_id=5470