id(a) == id(b) and a is not b --> bug?
gerrit at nl.linux.org
Thu Jun 5 21:49:59 CEST 2003
according to the reference manual:
The `is' operator compares the identity of two objects; the id() function returns an integer representing its identity
This would mean that "id(a) == id(b)" is the same as "a is b".
def __init__(cls, name, bases, dict):
s = super(cls)
setattr(cls, "super", s)
setattr(cls, "super2", s)
__metaclass__ = autosuper
print "id's equal =>", id(self.super) == id(self.super2)
print "same object =>", self.super is self.super2
$ python meta.py
id's equal => True
same object => False
Is this a bug? It is true both for Python 2.3b1+ and Python 2.2.
168. If a man wish to put his son out of his house, and declare before
the judge: "I want to put my son out," then the judge shall examine into
his reasons. If the son be guilty of no great fault, for which he can be
rightfully put out, the father shall not put him out.
-- 1780 BC, Hammurabi, Code of Law
Asperger Syndroom - een persoonlijke benadering:
Het zijn tijden om je zelf met politiek te bemoeien:
More information about the Python-list