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

Scott David Daniels Scott.Daniels at Acm.Org
Sun Mar 29 21:26:16 CEST 2009

Péter Szabó wrote:
> I think we have a different understanding what @override means. I
> define @override like this: ``class B(A): @override def F(self):
> pass'' is OK only if A.F is defined, i.e. there is a method F to
> override. What I understand about your mails is that your definition
> is: if there is @override on A.F, then any subclass of A must override
> A.F. Do I get the situation of the different understanding right? If
> so, do you find anything in my definition which prevents code reuse?
> (I don't.)

Nor do I.  I completely misunderstood what you meant by override, and I
agree that what you are specifying there _is_ a help to those writing
code (I'd document it as a way of marking an intentional override).

As to @final, I'd prefer a warning to an error when I override a
final method.   Overriding is a rich way of debugging, and if the
point is to catch coding "misteaks", ignoring warnings is easier
than changing package code when debugging.

--Scott David Daniels
Scott.Daniels at Acm.Org

More information about the Python-ideas mailing list