[Python-ideas] The prohibition overrides the class method

Ian Kelly ian.g.kelly at gmail.com
Mon Nov 16 18:40:26 EST 2015


On Nov 16, 2015 4:15 PM, "Michael Selik" <mike at selik.org> wrote:
>
> For that envelopes example on StackExchange, I'd probably use name
mangling to reduce chances of subclassing mistakes and have prepare() call
stuff(), seal(), stamp() in the correct order or whatever those were. I'm
not sold in the need for "final".

Name mangling would not work in that example. The prepare method is defined
by a base class and overridden in a subclass; it is the subclass that
wishes to declare the method final. Name mangling would obstruct overriding
the method at all, which would be a problem for the base class that invites
the method to be overridden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20151116/9cc915fb/attachment.html>


More information about the Python-ideas mailing list