Is " a is b " and " id(a) == id(b) " the same?

Aahz aahz at
Sun Mar 16 22:05:46 CET 2003

In article <Xp1da.94293$zo2.2505671 at>,
Alex Martelli  <aleax at> wrote:
>Yep -- you can also explicitly define attributes that are generated
>on the fly at each access and ensure this behavior (method objects
>currently _are_ generated on the fly at each access, but it's quite
>permissible for the language implementation to change and cache them
>in some cases in the future).  E.g., try:
>class X(object):
>    def __getattr__(self, name):
>        if name == 'f': return []
>        raise AttributeError, name
>class Y(object):
>    def getf(self): return []
>    f = property(getf)
>NOW, after a=X() or a=Y(), you can choose to:
>    assert a.f is not a.f

Aahz (aahz at           <*>

Register for PyCon now!

More information about the Python-list mailing list