S
Stephen Ferg
Python has a builtin class for staticmethod. Seems to me that Python
should also have a builtin class for abstractmethod. Something like
this...
#######################################
# simulated implementation of a new builtin class: abstractmethod
def abstractmethod(f):
methodName = f.__name__
def temp(self, *args, **kwargs):
raise NotImplementedError(
"Attempt to invoke unimplemented abstract method %s"
% methodName)
return temp
# example of using proposed builtin class: abstractmethod
class TestClass:
@abstractmethod
def TestMethod(self): pass
t = TestClass()
t.TestMethod() # call to abstract method raises exception
should also have a builtin class for abstractmethod. Something like
this...
#######################################
# simulated implementation of a new builtin class: abstractmethod
def abstractmethod(f):
methodName = f.__name__
def temp(self, *args, **kwargs):
raise NotImplementedError(
"Attempt to invoke unimplemented abstract method %s"
% methodName)
return temp
# example of using proposed builtin class: abstractmethod
class TestClass:
@abstractmethod
def TestMethod(self): pass
t = TestClass()
t.TestMethod() # call to abstract method raises exception