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

Guido van Rossum guido at python.org
Sun Mar 29 04:55:23 CEST 2009


On Sat, Mar 28, 2009 at 7:40 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Ben Finney wrote:
>> Péter Szabó <ptspts at gmail.com> writes:
>>
>>> If Python had method decorators @final (meaning: it is an error to
>>> override this method in any subclass)
>>
>> What use case is there for this? It would have to be quite strong to
>> override the Python philosophy that “we're all consenting adults
>> here”, and that the programmer of the subclass is the one who knows
>> best whether a method needs overriding.
>
> 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. Please note that I already suggested this be put in a 3rd
party package -- I'm not about to make these builtins.

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



More information about the Python-ideas mailing list