[Python-Dev] RE: Re: PEP 285: Adding a bool type

Gerald S. Williams gsw@agere.com
Wed, 3 Apr 2002 15:02:02 -0500


Guido van Rossum wrote:
> Tutorial should point this out.  It's poor coding style even in
> languages that do have strict Booleans, so I think it's a good idea to
> nip this one in the bud.

Agreed, although one of Python's big selling points (for me,
at least) is that you generally don't have to refer to the
manual to understand what's happening, even if you're new to
the language.

And something like this may be a bit more subtle, since it is
somewhat an issue of style. I don't expect people to go to
this extreme:

   if (a > b) is True:
      ...

But that would be valid code. There's probably *somebody* in
the world who would even prefer the useless "is True".

> What a waste to write "if bool(y) == True" instead of "if y" ... :-(

True again. I think we all agree that comparisons to True and
False would cause problems. I guess the question is how often
people would actually get tripped up by it. Or worse, *not*
get tripped up by it and start doing it regularly. :-)

I was thinking you could simply attack the problem by doing
something with the == and != operators, but that doesn't help
if you test using "is" or "is not". I'm not sure if managing
people's expectations ever really works, but perhaps that's
the only real answer (assuming the PEP is implemented).

-Jerry

-O Gerald S. Williams, 55A-134A-E   : mailto:gsw@agere.com O-
-O AGERE SYSTEMS, 6755 SNOWDRIFT RD : office:610-712-8661  O-
-O ALLENTOWN, PA, USA 18106-9353    : mobile:908-672-7592  O-