>>> class F(object): ... def t(self): ... print 'coucou' ... >>> def u(): ... print 'coucou' ... >>> def get_instance(func): ... if not hasattr(func, 'im_self'): ... return None ... return func.im_self ... >>> get_instance(u) >>> get_instance(g.t) <__main__.F object at 0x6c630>