In the style guide they do give a reason:
Inheritance with properties can be non-obvious if the property itself is not overridden. Thus one must make sure that accessor methods are called indirectly to ensure methods overridden in subclasses are called by the property (using the Template Method DP).
(where Template Method DP is the Template Method Design Pattern (slides by Alex Martelli, Pythonista extraordinaire at Google).
So they want to give subclasses the chance to override the implementation, and give the property
the triple-underscore versions to call the double-underscore methods so you can override these. You'd have to spell out the mangled name in that case:
class WonkySquare(Square):
def _Square__get_area(self):
return self.square ** 2 + 0.5
Apparently the people that came up with this scheme never knew that you can override just a getter or setter of a property, see Python overriding getter without setter:
class ProperlySubclassedSquare(Square):
@Square.area.getter
def area(self):
return self.square ** 2 + (0.5 - 0.5)
Then again, the getter
, setter
and deleter
decorator attributes were only added in Python 2.6. The style guide must've been written for an older Python version.
For 2.6 and up, stick to the @propname.setter
pattern instead.