"0 in [True,False]" returns True
Stefan Rank
stefan.rank at ofai.at
Tue Dec 13 06:04:19 EST 2005
on 13.12.2005 11:39 Fredrik Lundh said the following:
> Duncan Booth wrote:
>>Another reason to have a boolean type is of course to provide a cast:
>>
>> def isNameSet(self):
>> return boolean(self.name)
[snip]
>
> given that Python already had a function for this, that wasn't
> much of a reason:
>
>>>>help(operator.truth)
>
> Help on built-in function truth in module operator:
>
> truth(...)
> truth(a) -- Return True if a is true, False otherwise.
>
[snip]
As operator.truth() is equivalent to bool()
and as it is the only thing in operator that is not really reflecting an
operator, I had a look into PEP3000 to see if (the redundant)
operator.truth is going to be removed. It is not mentioned.
(not that I really care, but I thought I could provide something
productively new to discuss about, to end the "why is bool an int?"
discussion ;-)
stefan
More information about the Python-list
mailing list