data structuresalgorithmsand code simplification abstractmethod(methoda decorator that declares method to be abstract when used in an abstract base classderived classes defined directly via inheritance can only be instantiated if they define nonabstract implementation of the method this decorator has no effect on subclasses registered using the register(method of an abstract base abstractproperty(fget [fset [fdel [doc]]]creates an abstract property the parameters are the same as the normal property(function when used in an abstract basederived classes defined directly via inheritance can only be instantiated if they define nonabstract implementation of the property the following code provides an example of defining simple abstract classfrom abc import abcmetaabstractmethodabstractproperty class stackablein python use the syntax _metaclass_ abcmeta class stackable(metaclass=abcmeta@abstractmethod def push(self,item)pass @abstractmethod def pop(self)pass @abstractproperty def size(self)pass here is an example of class that derives from stackableclass stack(stackable)def _init_ (self)self items [def push(self,item)self items append(itemdef pop(self)return self items pop(here is the error message that you get if you try to create stacks stack(traceback (most recent call last)file ""line in typeerrorcan' instantiate abstract class stack with abstract methods size this error can be fixed by adding size(property to stack you can either do this by modifying the definition of stack itself or inheriting from it and adding the required method or propertyclass completestack(stack)@property def size(self)return len(self itemshere is an example of using the complete stack objects completestack( push("foo" size lib fl ff