Q about object identity
Tommy Grav
tgrav at mac.com
Fri Jun 6 17:15:42 EDT 2008
On Jun 6, 2008, at 4:27 PM, Ethan Furman wrote:
> vronskij at gmail.com wrote:
>> Hello,
>> I am testing object identity.
>> If I do it from the interpreter, I get strange results.
>>>>> *print [] is []*
>> *False*
>>>>> print id([]), id([])
>> 3083942700 3083942700
>> Why is that? Isn't this an error?
in the first statement the two []'s are in memory at the same
time and have different id() signatures. For the second statement
the first id([]) is evaluated and release from memory and then
the second id([]) is evaluated and release from memory. Since
only one of them exist at a time they can have the same id()
signature.
Cheers
Tommy
More information about the Python-list
mailing list