Message info
To:Cosmia Luna From:Ian Kelly Subject:Re: How to get a reference of the \'owner\' class to which a method belongs in Python 3.X? Date:Sun, 18 Mar 2012 10:14:12 -0600

On Sun, Mar 18, 2012 at 3:42 AM, Cosmia Luna <> wrote:
> But it seems that the last line(#ref2) in the Py2Type.__init__ does not work at
> all.

I'm not sure what you're expecting it to do, but type.__init__ does
not actually do anything

> It seems really weird, 'type' is an instance of 'type' itself, I'm not sure
> if I'm calling the unbound method __init__ or bound method __init__.

type.__init__ is never bound.

> It seems type.__new__ calls type.__init__ before it calls Py2Type.__init__,
> because dict_ is already copied to cls.__dict__ at line(#ref3).

No, type.__new__ does not call type.__init__ at all. Rather, it is
type.__new__ that is responsible for copying the dict, not
type.__init__. For this reason you should override type.__new__ in
your metaclass, not type.__init__.