I know I can implement in the base class some function to raise when subclass fails to override some method.
def some_method( self ):
raise NotImplementedError
But how can I do the opposite, i.e. raise only when the subclass does override this method?
Thanks!
Edit: I'm trying to prevent people from overriding getitem/getattr so the namespace clash doesn't apply here.
Edit: I already tried to check if the subclass method is base class method. This worked under CPython, but not PyPy. Is there any all-around solution?