I ran the following code in the Python interpreter:
>>> s
<sqlalchemy.orm.session.Session object at 0x7f4fc8d69e10>
>>> type(s)
<class 'sqlalchemy.orm.session.Session'>
>>> type(s) == sqlalchemy.orm.session.Session
False
(1) Why does the interpreter say the type of s
is not sqlalchemy.orm.session.Session
, when it just said that it was?
(2) If the type
command doesn't work, what is the best way to tell if an object is a Session
object? (I'm trying to use this in an assertion to validate the input to a function)
(3) Just for fun, I tried to do this with a primitive type, and it worked. Why are integers different here?
>>> type(3)
<type 'int'>
>>> type(3) == int
True