Q about object identity

vronskij at gmail.com vronskij at gmail.com
Tue Jun 3 22:56:36 CEST 2008


I am testing object identity.

If I do it from the interpreter, I get strange results.

>>> print [] is []

>>> print id([]), id([])
3083942700 3083942700

Why is that? Isn't this an error?

If I test it in a script, all is OK.


a = []
b = []

print a == b
print a is b

print id(a), id(b)

print id(None), id(None)
print id(True), id(True)

On my computer, I got these results:

3083769036 3083793516
135553336 135553336
135526444 135526444

All as expected.

jan bodnar

More information about the Python-list mailing list