[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Test 0 and false since false is 0

On 2017-07-07, Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> Sayth Renshaw <flebber.crue at gmail.com> writes:
>>I have tried or conditions of v == False etc but then the 0's
>>being false also aren't moved. How can you check this at
>       ?The Boolean type is a subtype of the integer type, and
>       Boolean values behave like the values 0 and 1,
>       respectively, in almost all contexts, the exception
>       being that when converted to a string, the strings
>       "False" or "True" are returned, respectively.?
>     The Python Language Reference, Release 3.6.0;
>     3.2 The standard type hierarchy 
>   So maybe you can add a test for the type?
>>>> def isfalse( x ):
> ...   return x == 0 and str( type( x )) == "<class 'bool'>"
> ...

What's wrong with the following?

  x is False

Isn't False a singleton value?

Grant Edwards               grant.b.edwards        Yow! I want a VEGETARIAN
                                  at               BURRITO to go ... with
                              gmail.com            EXTRA MSG!!