[Python-Dev] For review: PEP 285: Adding a bool type
Guido van Rossum
guido@python.org
Fri, 08 Mar 2002 17:09:27 -0500
> I didn't want to jump on the bandwagon, but...
>
> It occurs to me that one potential benefit of having a
> boolean type is to avoid mistakes like this:
>
> test = value & MASK
> if test == True:
> DoSomething()
>
> Sure, "if bool(test) == True:" does the right thing, but
> so does "if test:". You wouldn't have made the mistake
> in the first place if you'd thought of that. :-)
>
> I think at least add something like this should be added
> to the description in the PEP:
>
> def __cmp__(self,other):
> return int.__cmp__(self,bool(other))
Absolutely not. I want True == 2 to be False.
--Guido van Rossum (home page: http://www.python.org/~guido/)