isinstance(False, int)

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Mon Mar 8 03:53:47 EST 2010


Rolando Espinoza La Fuente a écrit :
> On Fri, Mar 5, 2010 at 2:32 PM, mk <mrkafk at gmail.com> wrote:
>> Arnaud Delobelle wrote:
>>
>>>>>> 1 == True
>>> True
>>>>>> 0 == False
>>> True
>>>
>>> So what's your question?
>> Well nothing I'm just kind of bewildered: I'd expect smth like that in Perl,
>> but not in Python.. Although I can understand the rationale after skimming
>> PEP 285, I still don't like it very much.
>>
> 
> So, the pythonic way to check for True/False should be:
> 
>>>> 1 is True
> False
> 
>>>> 0 is False
> False
> 
> instead of ==, right?

Nope. The pythonic way is to check for truth value - not for True or 
False -, and to only use the identity test when wanting to test for 
identity.




More information about the Python-list mailing list