
Péter Szabó wrote:
Hi,
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 http://www.math.bme.hu/~pts/pobjects_example.py
I have no idea why you want these, and severe trepidation about dealing with code that uses them "just to be safe." It smacks of the over-use I see of doubled underscores. For @override, just because you've built a base class for one kind of object does not mean I have not thought of an interesting way to use 40% of your code to accomplish my own end. Why make me cut and paste? You are not responsible for the correctness of my flea-brained idea whether I inherit from your class or not. For @final, "how dare you" for similar reasons. Java at least has an excuse (compilation can proceed differently). --Scott David Daniels Scott.Daniels@Acm.Org