In pyton code I've got a bound method of some object. Knowing only this bound method I would like to know what is the class of that object. Is it possible?
Here is sample code:
>>> class x:
... def method(self):
... pass
...
>>> x
<class __main__.x at 0xb737d1ac>
>>> x_instance = x()
>>> x_instance
<__main__.x instance at 0xb737c7cc>
>>> boundmethod = x_instance.method
>>> boundmethod
<bound method x.method of <__main__.x instance at 0xb737c7cc>>
>>> str(boundmethod)
'<bound method x.method of <__main__.x instance at 0xb737c7cc>>'
Let's assume I know only boundmethod
. How to determine that the class is x
?