PEP 285: Adding a bool type

Tim Peters tim.one at comcast.net
Sat Mar 30 17:29:29 EST 2002


[Guido]
>>     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.

[Paul Rubin]
> If cmp returns a boolean, it can no longer distinguish the 3 cases
> a < b, a == b, or a > b.  That is seriously broken.

He didn't suggest changing cmp.  He's saying that if functions that return
bools printed True/False instead of 1/0, people would be much less likely to
fall into the trap of believing cmp() returns a bool (cmp() would continue
to display not True/False, but little integers).





More information about the Python-list mailing list