descriptor dilemma

john crichton314 at tiscali.co.uk
Wed May 4 10:20:16 EDT 2005


Hello,

I was wondering if someone could explain the following situation to me
please:

>>> class C(object):
        def f(self):
                pass
>>> c = C()
>>> c.f
<bound method C.f of <__main__.C object at 0x00B25950>>
>>> C.__dict__['f'].__get__(c,C)
<bound method C.f of <__main__.C object at 0x00B25950>>
>>> c.f == C.__dict__['f'].__get__(c,C)
True
>>> c.f is C.__dict__['f'].__get__(c,C)
False

Why do c.f and C.__dict__['f'].__get__(c,C) compare as equal under ==
but not under *is*  ?

Thanks,

John




More information about the Python-list mailing list