Operator precedences
Steven Taschuk
staschuk at telusplanet.net
Tue Feb 25 21:36:28 EST 2003
Quoth Hans Nowak:
[...]
> 3 < 2 < 1 is equivalent to 3 < 2 and 2 < 1, including the shortcut effect of
> the and operator.
But not including any side-effects of the middle expression:
>>> def spam():
... global i
... i += 1
... return i
...
>>> i = 0
>>> 0 < spam() < 2
1
>>> i = 0
>>> 0 < spam() and spam() < 2
0
--
Steven Taschuk 7\ 7'Z {&~ .
staschuk at telusplanet.net Y r --/hG-
(__/ )_ 1^1`
More information about the Python-list
mailing list