[Python-ideas] Keyword for direct pass through of kwargs to super

Greg Ewing greg.ewing at canterbury.ac.nz
Mon May 28 19:52:04 EDT 2018

Michael Lohmann wrote:

>>    class Ethel(Aardvark, Clever):
>>        """Ethel is a very clever Aardvark"""
>>        def __init__(self):
>>            super().__init__(quantity="some spam", cleverness=1000))
>> if you want to instantiate an Aardvark directly there is NO WAY EVER that
>> you could give him ANY kwargs. So why should the __init__ indicate
>> something else?

You seem to want the signature of Ethel.__init__ to indicate exactly
what arguments it can accept.

But even with your proposed feature, that isn't going to happen.
It will only show arguments that appear explicitly in Ethel.__init__'s
argument list. If it didn't override the default value for cleverness,
you would never know that it was a possible parameter.

In situations like this there's no substitute for hand-written
documentation, and that can include explaining what is allowed
for **kwds.


More information about the Python-ideas mailing list