On Tue, Feb 12, 2013 at 8:35 AM, Guido van Rossum <gu...@python.org> wrote:
> On Mon, Feb 11, 2013 at 2:29 PM, Nick Coghlan <ncogh...@gmail.com> wrote:
>> 4.__class__ is already bound as soon as we have a class object to bind it
>> to, so we can't move it any earlier. However, it's already early enough to
>> let references to it from the new method (including the implied one in
>> zero-arg super) work properly. The black magic that is zero-arg super also
>> deals with PJE's concern about propagating the actual class up the MRO (as
>> it is equivalent to "super(__class__, first_argument)").
>
> So where is it not bound when a metaclass runs? I guess in the metaclass's
> __new__()? Because in the metaclass's __init__() it should exist IIUC.

I stand corrected, we don't *quite* bind it as soon as the class
object exists - we bind it as soon as the call to the metaclass
returns. So even though the class object exists when __init__ runs, it
isn't bound to __class__ yet. Given that the class construction
machinery treats the metaclass constructor as an opaque callable,
trying to get the cell binding to happen between the call to __new__
and the one to __init__ would be rather challenging (Translation: I'm
not sure where you would even start...).

Regards,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to