id(a) == id(b) and a is not b --> bug?
Martin v. Löwis
martin at v.loewis.de
Fri Jun 6 02:31:04 EDT 2003
Gerrit Holl <gerrit at nl.linux.org> writes:
> This would mean that "id(a) == id(b)" is the same as "a is b".
It doesn't, atleast not if a and b can be arbitrary expressions:
count=0
def foo():
global count
count+=1
if count<4:
return 1
return 2
print id(foo())==id(foo())
print foo() is foo()
If any kind of computation is performed in the arguments, the property
you assume may not hold.
Regards,
Martin
More information about the Python-list
mailing list