PEP 285: Adding a bool type

John Roth johnroth at ameritech.net
Sat Mar 30 18:24:08 EST 2002


"Martin v. Loewis" <martin at v.loewis.de> wrote in message
news:m3y9ga7z38.fsf at mira.informatik.hu-berlin.de...
> 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";
>
> Regards,
> Martin

I make it optimistically 180 functions. Given the reasonably
high quality of the standard library, "return None" almost
certainly means that the function does not have a return value,
not that the return value should be treated as False. Good
practice shouldn't be to return None if you meant False - the
convention is 1 or 0.

John Roth

>





More information about the Python-list mailing list