PEP 285: Adding a bool type

Steve Holden sholden at holdenweb.com
Mon Apr 1 16:49:49 EST 2002


"Gustavo Niemeyer" <niemeyer at conectiva.com> wrote in message
news:mailman.1017673984.1773.python-list at python.org...
> Hi Martin!
>
> > 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";
>
> I hope nobody is planning to change "return None" to "return False".
> This would break a lot of code doing "ret == None".
>
Arguably, most of that code should have read

    if ret:
        ...

rather than

    if ret == None:
        ...

since the latter has the flavor of "if expr==True".

So, is breaking bad code more excusable than breaking good code ;-)?

regards
 Steve







More information about the Python-list mailing list