Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is just a side-effect of bool being a subclass of int and True and False having the values 1 and 0, respectively. It might seem weird or surprising, but it's not a problem with Python's type system.

    >>> issubclass(bool, int)
    True
    >>> isinstance(True, int)
    True
    >>> int(True)
    1
    >>> int(False)
    0
    >>> True == 1
    True
    >>> False == 0
    True


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: