Steve R. Hastings wrote: > So, don't test to see if something is equal to True or False: > > if 0 == False: > pass # never executed; False and 0 do not directly compare
of course they do - ie isinstance(False,int) is True and False == 0 > > > You *could* do this, but I don't really recommend it: > > if bool(0) == False: > pass # always executed > > > Do this: > > if not 0: > pass # always executed > > if 1: > pass # always executed > > > To convert a random value into a boolean value, you could use either > "bool()" or you could use "not not": > > a = not not 0 > b = bool(0) > > > "not not" will work on older versions of Python that didn't have an > explicit boolean type; "not 0" would return 1 in that case. "bool()" > will work in Python 2.2 and newer. -- http://mail.python.org/mailman/listinfo/python-list