How to get a reference of the 'owner' class to which a method belongs in Python 3.X?

Chris Rebert clp2 at
Sat Mar 17 06:51:05 CET 2012

On Fri, Mar 16, 2012 at 10:30 PM, Cosmia Luna <cosmius at> wrote:
> I'm porting my existing work to Python 3.X, but...
> class Foo:
>    def bar(self):
>        pass
> mthd =
> assert mthd.im_class is Foo # this does not work in py3k
> So, how can I get a reference to Foo? This is important when writing
> decorators,

Could you give an example of such a decorator?


More information about the Python-list mailing list