PEP 285: Adding a bool type

Dan Schmidt dfan at harmonixmusic.com
Mon Apr 1 10:09:12 EST 2002


Paul Rubin <phr-n2002a at nightsong.com> writes:

| Guido van Rossum <guido at python.org> writes:
|
| >     There's also the issue (which I've seen puzzling even experienced
| >     Pythonistas who had been away from the language for a while) that if
| >     you see:
| > 
| >         >>> cmp(a, b)
| >         1
| >         >>> cmp(a, a)
| >         0
| >         >>> 
| > 
| >     you might be tempted to believe that cmp() also returned a truth
| >     value.  If ints are not (normally) used for Booleans results, this
| >     would stand out much more clearly as something completely
| >     different.
| 
| If cmp returns a boolean, it can no longer distinguish the 3 cases
| a < b, a == b, or a > b.  That is seriously broken.  

Guido is not proposing any change to cmp.  He's proposing that other
functions that actually do mean to return truth values return True or
False, rather than 0 or 1, so that people will not look at cmp output
and think "Oh, that looks just like boolean results."

Dan

-- 
http://www.dfan.org



More information about the Python-list mailing list