[Python-Dev] Submitting PEP 422 (Simple class initialization hook) for pronouncement (original) (raw)

Daniel Urban urban.dani+py at gmail.com
Sun Feb 10 21:51:39 CET 2013


On Sun, Feb 10, 2013 at 5:48 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:

However, it's hard to say if this "new way of doing it" doesn't come with its own can of worms. For example, would cooperative calls to "initclass" work if a superclass already defines it? Do implementors have to remember that? And is it clear how this should be done, e.g. what should normally go first, my own code or the superclass call? Supporting cooperative initclass() calls properly might actually be a good thing. Currently, there's only one metaclass, plus a sequence of decorators, which makes the setup rather static and sometimes tedious for subclasses that need to do certain things by themselves, but in addition to what happens already.

Cooperative multiple inheritance of init_class would work exactly the same way as it works e.g., for init of any other method (actually it is easier, since as Nick mentioned, the signature is always the same): init_class can simply use the zero argument form of super. There is a simple example in the tests at http://bugs.python.org/issue17044.

Daniel



More information about the Python-Dev mailing list