Why does this print False in Python 3?
>>> 1 == int
False
Why does this print False in Python 3?
>>> 1 == int
False
Because that isn't at all doing what you think it is. You are comparing the integer value 1
with the type int
; naturally they are not equal.
If you want to check whether an object is of a certain type, use isinstance
:
isinstance(1, int)
I guess, what you want to use is this:
>>> type(1) is int
True
or
>>> type(1) == int
True