3

The problem is described like the following step:

class A():
    def b(self):
        pass
>>> A.b
<unbound method A.b>
>>> id(A.b)
140015897411408
>>> id(A.b)
140015897243552
>>> A.b
<unbound method A.b>
>>> id(A.b)
140015897411408
>>> id(A.b)
140015897243552
>>> id(A.b)
140015897243552

As we can see, id(A.b) is 140015897411408 first time and then it changes to 140015897243552 2nd time and then A.b is evaluated,and the same thing happens again.

why the id of the method is changing?

Spybdai
  • 179
  • 6
  • Can't replicate this behaviour in CPython 3.4, however, it does occur in Python 2.7. You should define the Python version that you are using. – mhawke May 09 '16 at 01:46
  • 2
    http://stackoverflow.com/questions/13348031/python-bound-and-unbound-method-object – Hooting May 09 '16 at 02:00

0 Answers0