Possible Duplicate:
Final classes in Python 3.x- something Guido isn't telling me?
I was watching a talk (How to design a good API and why it matters) in which it was said, literally, “design and document for inheritance, else prohibit it“. The talk was using Java as an example, where there’s the ‘final‘ keyword for prohibiting subclassing. Is it possible to prohibit subclassing in Python? If yes, it’d be great to see an example…
Thanks.
There is no Python keyword for this – it is not Pythonic.
Whether a class can be subclassed is determined by a flag called Py_TPFLAGS_BASETYPE which can be set via the C API.
You can however emulate the behaviour using only Python code if you wish:
Source