bool behavior in Python 3000?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed Jul 11 10:04:04 EDT 2007
On Wed, 11 Jul 2007 00:37:38 -0700, Rob Wolfe wrote:
> Steven D'Aprano wrote:
>
>> From a purely functional perspective, bools are unnecessary in Python. I
>> think of True and False as syntactic sugar. But they shouldn't be
>> syntactic sugar for 1 and 0 any more than they should be syntactic sugar
>> for {"x": "foo"} and {}.
>
> But `bools` are usefull in some contexts. Consider this:
>
>>>> 1 == 1
> True
>>>> cmp(1, 1)
> 0
>>>> 1 == 2
> False
>>>> cmp(1, 2)
> -1
>
> At first look you can see that `cmp` does not return boolean value
> what not for all newbies is so obvious.
Sorry I fail to see your point!? What has ``==`` to do with `cmp()` here?
The return of `cmp()` is an integer that cannot and should not be seen as
boolean value.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list