About
Articles Related
Management
Creation
Use the ABCMeta metaclass to create an ABC.
from abc import ABCMeta, abstractmethod
class MyAbstractClass(object):
# specifying that is an abstract class
__metaclass__ = ABCMeta
# An attribute
name = None
def __init__(self, name):
self.name = name
@abstractmethod
def my_abstract_method(self):
"""
blablabla
:return: None
"""
return
Implementation
class MyClassImplementation(MyAbstractClass):
def __init__(self):
super().__init__("name")
def my_abstract_method(self):
"""
echo name
:return: None
"""
print (self.name)
return