Duncan Booth duncan at
Thu Apr 24 10:34:38 CEST 2003

martin at (Martin v. =?iso-8859-15?q?L=F6wis?=) wrote in 
news:m34r4pgh33.fsf at

> Ian Bicking <ianb at> writes:
>> Note that the idiom I've been using (and which I've seen elsewhere) is:
>> True, False = 1==1, 0==1
>> Which retains proper boolean objects.
> 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.

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 

Duncan Booth                                             duncan at
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?

More information about the Python-list mailing list