Skip to main content
formatting
Source Link
sth
  • 231k
  • 56
  • 288
  • 370

a = 0 if a == False: print a

a = 0
if a == False:
   print a

in php I can say: $a = 0; if $a === false { echo $a; }

$a = 0;
if $a === false {
    echo $a;
}

theThe triple === in php check for the value within the same type, thus making the integer 0 not be read as a boolean value False How can I do this in python? I would like to differentiate between 0 the integer and False the boolean value in a simple if statement.

a = 0 if a == False: print a

in php I can say: $a = 0; if $a === false { echo $a; }

the triple === in php check for the value within the same type, thus making the integer 0 not be read as a boolean value False How can I do this in python? I would like to differentiate between 0 the integer and False the boolean value in a simple if statement.

a = 0
if a == False:
   print a

in php I can say:

$a = 0;
if $a === false {
    echo $a;
}

The triple === in php check for the value within the same type, thus making the integer 0 not be read as a boolean value False How can I do this in python? I would like to differentiate between 0 the integer and False the boolean value in a simple if statement.

Source Link
Bob
  • 41
  • 1

Checking for value within same type in python

a = 0 if a == False: print a

in php I can say: $a = 0; if $a === false { echo $a; }

the triple === in php check for the value within the same type, thus making the integer 0 not be read as a boolean value False How can I do this in python? I would like to differentiate between 0 the integer and False the boolean value in a simple if statement.