[Python-Dev] Dictionary evaluation order
Guido van Rossum
guido@python.org
Tue, 26 Nov 2002 01:40:06 -0500
> I was just looking at the bug
>
> [#448679] Left to right
>
> It mentions that code like that
>
> {f1():f2(), f3():f4()}
>
> Will call these functions in the order f2, f1, f4, f3. What should we
> do about it? Tim mentions that "When [Tim] asked Guido about that
> some years ago, he agreed it was a bug.". Is it too late to fix it, or
> is it still a desirable fix?
Hm, there are other situations where it's not so easy to get strict
L2R evaluation, e.g.
a = {}
a[f1()] = f2()
It's rather natural to evaluate the RHS first in assignments. Since
the dict display is a thinly veiled assignment, I'm not sure it's
worth fixing this in the language definition. What does Jython do?
--Guido van Rossum (home page: http://www.python.org/~guido/)