[issue44090] Add class binding to unbound super objects for allowing autosuper with class methods

Raymond Hettinger report at bugs.python.org
Fri Mar 25 21:42:20 EDT 2022


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

Guido, what do you think about this proposal?  

Personally, I'm dubious about changing the meaning of the arguments between code paths.  The callee has no way to distinguish which meaning was intended.  And adding classmethod() support in super_descr_get() would create tight coupling where there should be separate concerns (no other descriptor call is classmethod specific).  

On StackOverflow, there has been some mild interest in the interactions between super() and classmethod():

* https://stackoverflow.com/questions/64637174
* https://stackoverflow.com/questions/1269217
* https://stackoverflow.com/questions/1817183

The OP's proposed use case is mildly plausible though I've never seen it the arise in practice.  The GoF factory pattern is typically implemented in a function rather than in the class itself — for example the open() function returns one of two different classes depending on the text or binary file mode.  It is rare to see __new__ used to fork off different types based on a parameter.  Presumably, it would be even more rare with a classmethod.  Also, it's not clear that the GoF pattern would mesh well with our cooperative super() since the upstream parent class isn't known in advance.

----------
nosy: +gvanrossum

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44090>
_______________________________________


More information about the Python-bugs-list mailing list