<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 4, 2013 at 5:21 AM, Chris Withers <span dir="ltr"><<a href="mailto:chris@simplistix.co.uk" target="_blank">chris@simplistix.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
In Python 2, I can figure out whether I have a method or a function, and, more importantly, for an unbound method, I can figure out what class the method belongs to:<br>
<br>
>>> class MyClass(object):<br>
... def method(self): pass<br>
...<br>
>>> MyClass.method<br>
<unbound method MyClass.method><br>
>>> MyClass.method.im_class<br>
<class '__main__.MyClass'><br>
<br>
There doesn't appear to be any way in Python 3 to do this, which is a little surprising and frustrating...<br>
<br>
What am I missing here?</blockquote><div><br></div><div>You could always monkeypatch builtins.__build_class__ to add an attribute to every "unbound method" pointing to the class.</div><div><br></div><div>-eric</div>
</div></div></div>