[Python-ideas] method decorators @final and @override in Python 2.4
tleeuwenburg at gmail.com
Sat Mar 28 23:29:30 CET 2009
Just thinking... this sounds rather like trying to bolt interfaces into
Python. In the 'consenting adults' view, shouldn't you be able to override a
method that you inherit if you would like to? I can well imagine some
well-meaning library author protecting some method with @final, then me
spending hours cursing under my breath because I am unable to tweak the
functionality in some new direction.
If I understand what you are suggesting correctly, then I'm -1 on the idea.
I would suggest that a good docstring could do the job just as well --
"Don't override this method in subclasses!".
Do you have any use cases to highlight the problem you are trying to fix
with this suggestion?
2009/3/29 Péter Szabó <ptspts at gmail.com>
> If Python had method decorators @final (meaning: it is an error to
> override this method in any subclass) and @override (meaning: it is an
> error not having this method in a superclass), I would use them in my
> projects (some of them approaching 20 000 lines of Python code) and
> I'll feel more confident writing object-oriented Python code. Java
> already has similar decorators or specifiers. Do you think it is a
> good idea to have these in Python?
> I've created a proof-of-concept implementation, which uses
> metaclasses, and it works in Python 2.4 an Python 2.5. See
> http://www.math.bme.hu/~pts/pobjects.py and
> Best regards,
> Python-ideas mailing list
> Python-ideas at python.org
"Don't believe everything you think"
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas