[Python-Dev] For review: PEP 285: Adding a bool type

Gerald S. Williams gsw@agere.com
Fri, 8 Mar 2002 16:07:56 -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))

-Jerry

-O Gerald S. Williams, 22Y-103GA : mailto:gsw@agere.com O-
-O AGERE SYSTEMS, 555 UNION BLVD : office:610-712-8661  O-
-O ALLENTOWN, PA, USA 18109-3286 : mobile:908-672-7592  O-