"0 in [True,False]" returns True
bonono at gmail.com
bonono at gmail.com
Tue Dec 13 10:28:33 EST 2005
Grant Edwards wrote:
> > He seems to be testing "boolean type", not whether it is true
> > or false.
>
> Right. But that's almost always pointless. Knowing whether a
> variable is a boolean or not is very rarely useful. What one
> wants to know is whether a varible is true or not. The code for
> that is:
>
> if v:
> something
>
> if not v:
> something
>
He doesn't want to know whether a variable is true or not, but whether
it is a boolean value. He seems to use the same variable to store both
boolean value, as well as other data type(see another post by OP) for
distinct meaning. Whether this is a good design is another matter and
debatable. Within Python, I think it is not needed as 1/0 and
True/False are basically interchangeable no matter where it is used.
More information about the Python-list
mailing list