bool behavior in Python 3000?
Rob Wolfe
rw at smsnet.pl
Wed Jul 11 03:37:38 EDT 2007
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.
Rob
More information about the Python-list
mailing list