Newcomer struggling with tutorial
Andrew Koenig
ark at acm.org
Sun Oct 5 12:25:02 EDT 2003
CPK> "Tim Peters" <tim.one at comcast.net> wrote in
CPK> news:mailman.1065325869.29360.python-list at python.org:
>> Perhaps that's confusing you.).
CPK> Yes. I screwed up with my example and I'm sorry to waste people's time. I
CPK> was getting confused.
CPK> What I found so disturbing is that
CPK> a < b == c
CPK> is not equivalent either to
CPK> (a < b) == c
CPK> nor to
CPK> a < (b == c)
CPK> since (given that for example (a, b, c) == (-1, 77, 1)) the first
CPK> is false while the latter are both true.
Right.
a < b == c
is equivalent to
(a < b) and (b == c)
except that b is evaluated only once in the first example. This behavior
is most useful when both relations are of the same kind, such as
if 0 <= n < 10:
# ...
--
Andrew Koenig, ark at acm.org
More information about the Python-list
mailing list