PEP 285: Adding a bool type

Peter Hansen peter at engcorp.com
Sat Mar 30 12:42:39 EST 2002


"Martin v. Loewis" wrote:
> 
> Peter Hansen <peter at engcorp.com> writes:
> 
> > Are there code snippets which clearly have significantly improved
> > readability as a result of a rewrite using the proposed bool?
> 
> The standard library has 110 occurrences of "return 0", 70 occurrences
> of "return 1", and 136 occurrences of "return None". Optimistically,
> this makes 300 functions. It would help users of these 300 functions
> if they would know whether those functions return a boolean or an
> integral value (if integral, what range?); for the "return None"
> cases, the boolean type would help to clarify whether this is "return
> no value", "return False", or "return nil object";

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?

If that is _all_ this change does, I suppose it would be okay.
If it in _any way_ changes the functionality one can currently
expect for those return values, such as the ability to use as
indices into a sequence, then I'm still very -1.

I like Greg's response too.  The improved readability does not
appear to outweigh the disadvantages of making Python's special
behaviour clear.

Furthermore, there will be code breakage, and that should always
rate very high on the list of reasons to leave well enough alone.

-Peter



More information about the Python-list mailing list