PEP 285: Adding a bool type

Peter Hansen peter at engcorp.com
Sun Mar 31 01:44:33 EST 2002


"Martin v. Loewis" wrote:
> 
> Peter Hansen <peter at engcorp.com> writes:
> 
> > So does this change proposes to change the readability so that
> > it is clear at a glance (at the source, not the documentation, which
> > seems an odd thing to base this on) that those functions return
> > boolean conditions rather than integers?
> 
> The documentation should change as all, documenting that certain
> functions return bool.

But your point in the message I was replying to was that there
are 300 functions which have code that says "return 0" or "return 1"
or "return None" and the change will help users of those functions.  
Didn't that imply those users are not looking at the documentation,
but are trying to read the source to figure out how the code works?
If the documentation must be changed, why not just make it clear
in the documentation what it means when a method returns 1 or 0 or None?

> > Furthermore, there will be code breakage, and that should always
> > rate very high on the list of reasons to leave well enough alone.
> 
> Can you show examples of (real!) code that will break? Preferably code
> you've written yourself.

I don't even need to dig up examples since I so often put this
code at the start of my modules:

True, False = 1, 0

Or, now that I think of it, will that continue to work as these
will just be built-ins now hidden by my local definitions?  If so,
my bad for mentioning code breakage.

-Peter



More information about the Python-list mailing list