0

This is pretty bizarre...I take user input from the command line and execute parts of my script depending on what that input is. I used ast.literal_eval() in order to determine whether or not the user is inputting an int, a bool, etc. I was having some trouble executing some parts of it, and that lead me to this:

I have a program:

value = True
print(type(value))
print(isinstance(value, bool))
print(isinstance(value, int))
print(isinstance(value, float))
print(isinstance(value, str))

that returns:

<class 'bool'>
True
True
False
False

Any idea why isinstance(value, int) is returning True when value is a bool?

Dhruv Pillai
  • 112
  • 4

0 Answers0