Question

I'd like to designate some of my baseclass functions for override. (The override should not be necessarily enforced.) What is the proper way of doing this?

I mean sth like

class Base(object):
    ...
    @abstractmethod
    def fun(self):
        pass

class Derived(Base):

    @override
    def fun(self):
        pass

EDIT:

I want my code to raise an UnimplementedException if the function is not overridden.

Was it helpful?

Solution

class Base(object):
    ...
    def fun(self):
        raise NotImplementedError

Source: http://julien.danjou.info/blog/2013/guide-python-static-class-abstract-methods

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top