"Delaney, Timothy (Tim)" <[EMAIL PROTECTED]> wrote in message news:[EMAIL
PROTECTED]
and several other people responded with similar information.
[...]
Bound methods are created on the fly.
[...]
Ahhh! That was the piece I was missing. Thank you all!
--
http://mail.python.org/mailman/listinf
a.m1 returns a bound method which gets freed before you try checking a.m2,
which ends up getting the same peice of memory. If you save a reference to
the bound methods, they are forced to have separate objects.
>>> class A:
... def m1(self): print "m1"
... def m2(self): print "m2"
...
>>> a =
> # ok, both methods work and give the expected results
> # so i presume they are different methods.
>
id(a.m1)
>
> 9202984
>
id(a.m2)
>
> 9202984
>
id(a.m1)==id(a.m2)
>
> True
> # Huh? They seem to be the same.
What you observe is rooted in two things:
- python objects bound
Stuart McGraw wrote:
> The following was cut and pasted exactly (except for the
> # lines which I added after the fact) from an interactive python
> session in a Window 2000 cmd.exe window.
>
> Can somebody please explain to me what the heck is
> going on?!?!
>
> Python 2.4.2 (#67, Sep 28 2005, 12
Stuart McGraw wrote:
> Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
> on win32 Type "help", "copyright", "credits" or "license" for more
> information.
class A:
> ... def m1(self): print "m1"
> ... def m2(self): print "m2"
> ...
a = A()
a.m1()
> m1
a