PEP 285: Adding a bool type

Gustavo Niemeyer niemeyer at conectiva.com
Tue Apr 2 09:17:45 EST 2002


> 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 ;-)?

It should be "if not ret", and most of the time this is a matter of
taste (some times you just have to do this, since you want to check for
"None", and not for 0). Nevertheless, this is a valid construct, and
not uncommon (indeed, I have no problems with this). If you don't
like this, don't use for yourself, but language design is much more than
"I don't like this so everyone using it should burn".

-- 
Gustavo Niemeyer

[ 2AAC 7928 0FBF 0299 5EB5  60E2 2253 B29A 6664 3A0C ]




More information about the Python-list mailing list