Tim Peters <[email protected]> added the comment:
I think Dennis's example is fatal: from section 6.10 ("Comparisons"):
"""
Comparisons can be chained arbitrarily, e.g., `x < y <= z` is equivalent to `x
< y and y <= z`, except that y is evaluated only once (but in both cases z is
not evaluated at all when x < y is found to be false).
"""
So doing LOAD_FAST twice on x (in `1 < x < 3`) is prohibited by the language
definition. Doesn't matter to this whether it's plain `x` or `f(x)` where `f()`
is some arbitrary function: the object the middle comparand signifies is fixed
at whatever it was when the the first comparison is evaluated.
----------
nosy: +tim.peters
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45542>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com