if the else short form

Andreas Waldenburger usenot at geekmail.INVALID
Wed Sep 29 11:47:01 EDT 2010


On Wed, 29 Sep 2010 08:53:17 -0400 Philip Semanchuk
<philip at semanchuk.com> wrote:

> Does Python make any guarantee that int(True) == 1 and int(False) ==
> 0 will always hold, or are their values an implementation detail?
> 

<http://docs.python.org/release/3.1/reference/datamodel.html#the-standard-type-hierarchy>

Booleans (bool)

    These represent the truth values False and True. The two objects
    representing the values False and True are the only Boolean
    objects. The Boolean type is a subtype of the integer type, and
    Boolean values behave like the values 0 and 1, respectively, in
    almost all contexts, the exception being that when converted to a
    string, the strings "False" or "True" are returned, respectively.


/W


-- 
INVALID? DE!




More information about the Python-list mailing list