This question already has an answer here:
I run the following in the Python interpreter:
>>> foo = 10
>>> dir(foo) == dir(10)
True
>>> dir(foo) is dir(10)
False
>>>
Why is this?
This question already has an answer here:
I run the following in the Python interpreter:
>>> foo = 10
>>> dir(foo) == dir(10)
True
>>> dir(foo) is dir(10)
False
>>>
Why is this?
is
checks that 2 arguments refer to the same object,==
checks that 2 arguments have the same value.dir()
returns alist
which contains the same data for bothfoo
and10
, but the actuallist
instances for the 2 things are different.