Python super and setting parent class property

I was trying to find the correct language to back up why this behavior is the way it is, so as not to give you a “because it just is” answer… But it seems this question has been asked more than once, and that it boils down to the behavior of super(). You can see a 2010 discussion about this exact behavior here: http://mail.python.org/pipermail/python-dev/2010-April/099672.html

Ultimately, it really does just come down to super() calls only letting you access getters directly, and not setters. Setters must be accessed via fset() or __set__(). It is probably easiest explained as “super() functionality just doesn’t support it”. It will resolve the property functionality of a “get” operation, not the setter in a left handed assignment, in the “set” operation (hence the fset() method call). As you can see from the date of this discussion thread, its obviously been this way since the introduction of super().

Maybe someone else has a more specifically technical reason, but frankly I’m not sure it even matters. If its not supported, thats pretty much a good enough reason.

Leave a Comment