Jeff Epler wrote:
> > >>> id(c.f) == id(C.__dict__['f'].__get__(c,C))
> > True
>
> Here, c.f is discarded by the time the right-hand-side of == is
> executed. So the object whose id() is being calculated on the
> right-hand-side could turn out to be the same, since the two objects
> have disjoint
john wrote:
> Why do c.f and C.__dict__['f'].__get__(c,C) compare as equal under ==
> but not under *is* ?
These variations are equivalent. Every attribute access gives you a new
bound method:
>>> class C(object):
... def f(self): pass
...
>>> c = C()
>>> c.f is c.f
False
>>> c.f == c.f
Tr
On Wed, May 04, 2005 at 09:14:18AM -0700, Sébastien Boisgérault wrote:
>
> Yup ?!? Weird ... especially as:
>
> >>> id(c.f) == id(C.__dict__['f'].__get__(c,C))
> True
Here, c.f is discarded by the time the right-hand-side of == is
executed. So the object whose id() is being calculated on the
ri
Yup ?!? Weird ... especially as:
>>> id(c.f) == id(C.__dict__['f'].__get__(c,C))
True
I was pretty sure that 'id(a) == id(b)' iff 'a is b' ...
I thought initially that you had two *copies* of the
same method bot obviously it's not true ...
SB
--
http://mail.python.org/mailman/listinfo/python
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
>
>>> C.__dict__['f'].__get__(c,C)
>
>>> c.f == C.__dict__['f'].__get__(c,C)
True
>>> c.f is C.__dict__['f'].__get__(c,C)
False