How to test if an object IS another object?
eloff777 at yahoo.com
eloff777 at yahoo.com
Sun Jun 12 16:49:13 EDT 2005
Fascinating. With small strings, it uses the same object, and with
small numbers like 3. With 300 they were different objects (why,
shouldn't they both be ints still?)
Mutable objects functioned differently as you suggested:
>>>foo = []
>>>bar = []
>>>foo == bar
True
>>>foo is bar
False
Tuples (which are immutable) also appear to be reused
>>>foo = ()
>>>bar = ()
>>>foo is bar
True
Thanks for your help, I know how to solve the problem now.
-Dan
More information about the Python-list
mailing list