[issue14965] super() and property inheritance behavior

Raymond Hettinger report at bugs.python.org
Wed Dec 8 22:06:20 EST 2021


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

-0 from me as well.  I don't think this is common or something that should be encouraged.  As Andrew points out, "del super().x" doesn't have an obvious meaning and it could be regarded as a code smell.

The OP's first example would be an unpleasant API to debug -- it exhibits tight coupling between the parent and child class, it has Liskov issues, and it has implicit forwarding and indirection through descriptors.  The tight coupling is especially problematic because Python's super() isn't guaranteed to call the parent class; rather, it can call a sibling class as determined by the MRO which cannot be known at the time the class is written.

Another thought is that super() is intentionally not a completely transparent proxy.  While an explicit call super().__getitem__(k) works, we've denied support for super()[k].  To me, "super().x = 10" and "del super().x" fall in the same category.

Looking at the OP's 

Fortunately, it doesn't seem to be a common need to use super() in a property setter or deleter to bypass the current class and call setter or deleter in a parent class property.  Arguably, this kind of tight coupling isn't good design.  The OP's first example would be an unpleasant API to debug.

FWIW,

----------
nosy: +rhettinger
versions:  -Python 3.10, Python 3.9

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


More information about the Python-bugs-list mailing list