Inverse of hasattr in Python
<p><code>hasattr(obj, attribute)</code> is used to check if an object has the specified attribute but given an attribute is there a way to know where (all) it is defined?</p>

<p>Assume that my code is getting the name of an attribute (or a classmethod) as string and I want to invoke <code>classname.attribute</code> but I don't have the classname.</p>

<p>One solution that comes to my mind is this</p>

<pre><code>def finder(attr):
    for obj in globals():
        try:
            if globals()[obj].__dict__[attr]:
                return(globals()[obj])
        except:
            ...
</code></pre>

<p>usage:</p>

<pre><code>class Lime(object):
    @classmethod
    def lfunc(self):
        print('Classic')

getattr(finder('lfunc'),'lfunc')() #Runs lfunc method of Lime class
</code></pre>

<p>I am quite sure that this is not the best (oe even proper way) to do it. Can someone please provide a better way.</p>
