Python quirk in evaluation order
__peter__ at web.de
Fri Jul 31 22:39:25 CEST 2009
James Stroud wrote:
> py> b = 4 if True else b
> py> b
> Isn't the right side supposed to be evaluated first?
Perhaps it becomes clearer if you change it a bit:
>>> b = 4 if True else whatever
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'whatever' is not defined
I. e. the else clause is never evaluated at all.
More information about the Python-list