How to prevent a function from being overridden in python

olamundo picture olamundo · Mar 11, 2010 · Viewed 14.2k times · Source

Is there a way to make a class function unoverriddable? something like java's final keyword. i.e, any overriding class cannot override that method.

Answer

Michael Kristofik picture Michael Kristofik · Mar 11, 2010

You could put a comment in there to the effect of:

# We'll fire you if you override this method.

It's surprising how well low-tech solutions like this work in practice.