[Python-ideas] method decorators @final and @override in Python 2.4
grosser.meister.morti at gmx.net
Sat Mar 28 16:21:51 CET 2009
Péter Szabó wrote:
> 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,
+1 on the idea.
however, using a metaclass would be to limiting imho. can you implement it in a
different way? a lot of things people use metaclasses for work perfectly fine
without them (instead use a superclass that overrides __new__ or similar).
More information about the Python-ideas