True/False

Martin v. Löwis martin at v.loewis.de
Thu Apr 24 16:03:19 EDT 2003


Duncan Booth <duncan at NOSPAMrcp.co.uk> writes:

> > For Python 2.x, this does not really matter much. Yes, you do get
> > references to Py_True/Py_False, but they are still just integer
> > objects with the value 1/0.
> 
> Not entirely accurate. In Python 2.3, True and False have type bool which 
> is a subclass of int, so this could make a difference.

Right; I meant x < 3.

> Even in Python 2.1 & 2.2 there can be a subtle difference. If, for example, 
> you use the win32 extensions to access COM objects, then calling a COM 
> method that accepts a variant type with 1 as a parameter will pass an 
> integer, but 1==1 will make it pass a boolean. The win32 com support did 
> some strange tricks with object identity to tell integers and booleans 
> apart.

I see. Sounds very hacky.

Regards,
Martin




More information about the Python-list mailing list