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

Guido van Rossum guido at python.org
Sun Mar 29 05:18:38 CEST 2009

On Sat, Mar 28, 2009 at 10:14 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> 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).

To paraphrase a cliche: "Having 'private' (or 'final') in a language
doesn't cause unusable software. People using 'private' (or 'final')
indiscriminately cause unusable software." :-)

> 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).

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-ideas mailing list