1 > 0 == True -> False
Jussi Piitulainen
jpiitula at ling.helsinki.fi
Thu Jan 30 06:46:48 EST 2014
Thibault Langlois writes:
> Hello,
>
> $ python
> Python 2.7.4 (default, Sep 26 2013, 03:20:26)
> [GCC 4.7.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> 1 > 0 == True
> False
> >>> (1 > 0) == True
> True
> >>> 1 > (0 == True)
> True
> >>>
>
> What am I missing here ?
One or both of the following:
>>> 0 == True
False
>>> True and False
False
>>> 1 > 0
True
Or the fact that (1 > 0 == True) means ((1 > 0) and (0 == True)),
where each expression in such a chain is evaluated once, though in
this case it really does not matter since 0 is a literal.
Hm, I don't know if the evaluation short-circuits. I think not, but
I've never needed to know, and I don't need to know now.
More information about the Python-list
mailing list