[Python-ideas] method decorators @final and @override in Python 2.4

Nick Coghlan ncoghlan at gmail.com
Sun Mar 29 05:14:42 CEST 2009

Guido van Rossum wrote:
> On Sat, Mar 28, 2009 at 7:40 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> Agreed - the base class author has no right to tell subclass authors
>> that they *can't* do something.
> I'm sorry, but this is going too far. There are plenty of situations
> where, indeed, this ought to be only a hint, but I think it goes to
> far to say that a base class can never have the last word about
> something.

Sorry, what I wrote was broader in scope than what I actually meant. I
only intended to refer to otherwise arbitrary non-functional constraints
like marking elements of the base as "private" or "final" without giving
a subclass author a way to override them (after all, even name mangling
can be reversed with sufficient motivation).

A base class obviously needs to impose some real constraints on
subclasses in practice, or it isn't going to be a very useful (if
nothing else, it needs to set down the details of the shared API).


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-ideas mailing list