id() collisions on bound methods [was: metaclass and customizationwith parameters]

R

Robert Brewer

Andrew said:
Hmmm... If I create MyClass as above, I get the following results
which I don't understand:

<bound method MyClass.newmethod of <__main__.MyClass instance
at 0x008E93A0>>
<bound method MyClass.newmethod of <__main__.MyClass instance
at 0x008E93A0>>
9355504

Why do mc.method0 and mc.method1 appear to be the same object?

Even more confusing to me is:

... def method0(self):
... pass
... def method1(self):
... pass
... def method2(self):
... pass
...
9918464

Here f.method1 and f.method2 share the same id, which is different to
that of f.method1...

Can anyone enlighten me as to why this happens?
...further:
18536648

....so the id() result is mutating somehow, even for the same object.
This is true for both old- and new-style classes, by the way, and also
holds for methods where you don't simply pass (I tried return 0,
return1, and return 2, for example function bodies)

Hmmm...


Robert Brewer
MIS
Amor Ministries
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top