PEP 285: Adding a bool type
Steve Holden
sholden at holdenweb.com
Tue Apr 2 07:06:08 EST 2002
----- Original Message -----
From: "Max M" <maxm at mxm.dk>
Newsgroups: comp.lang.python
To: "Steve Holden" <sholden at holdenweb.com>
Sent: Tuesday, April 02, 2002 2:30 AM
Subject: Re: PEP 285: Adding a bool type
> Steve Holden wrote:
>
>
> > 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 ;-)?
>
>
> Oh I don't think so. This is a common idiom:
>
> def f(names=None):
> if names == None:
> names = []
> ...
>
Should anyway have been
if not ret:
...
but certainly when you are chossing between two false values you have to be
explicit about which is the sentinel.
regards
Steve
More information about the Python-list
mailing list