[Python-Dev] super() does not work during class initialization

Nick Coghlan ncoghlan at gmail.com
Sat Mar 21 13:11:41 CET 2015


On 21 March 2015 at 00:03, Martin Teichmann <lkb.teichmann at gmail.com> wrote:
> The current python fails the assertion, while with my patch everything is fine,
> and I personally think __class__ should always actually refer to the class being
> defined, which means at the minimum that it is actually, well, a class.

For folks that haven't looked at the tracker issue: I personally like
the change, but it does involve storing the cell object in a
dunder-variable in the class namespace while it's being defined (until
type.__new__ executes and both populates it and removes it from the
class namespace).

Since it introduces new behaviour that's visible to Python level code,
I've suggested that Martin roll the suggestion into his current PEP
487 (which adds __init_subclass__ to similarly tidy up a few
challenges with the way classes are currently initialised).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list