Checking whether bool is a type

Martin v. Löwis martin at v.loewis.de
Sun Jul 27 17:36:43 EDT 2003


Jan Decaluwe <jan at jandecaluwe.com> writes:

> jand> python2.2
> Python 2.2.2 (#1, Oct 16 2002, 19:59:11) 
> [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> type(bool) is type
> 0
> 
> Great isn't it ?! Not sure whether I should consider
> this to be completely obvious or very deep ...

Very obvious.

Python 2.2.1 (#1, Sep 10 2002, 17:49:17)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> bool
<built-in function bool>

bool is a function in Python 2.2.1+, not a type. It became a type only
in Python 2.3, see PEP 285.

Regards,
Martin




More information about the Python-list mailing list