abc.ABCMeta.register()

register(subclass) Register subclass as a “virtual subclass” of this ABC. For example: from abc import ABCMeta class MyABC(metaclass=ABCMeta): pass MyABC.register(tuple) assert issubclass(tuple, MyABC) assert isinstance((), MyABC) Changed in version 3.3: Returns the registered subclass, to allow usage as a class decorator. Changed in version 3.4: To detect calls to register(), you can use the get_cache_token() function.

abc.ABCMeta

class abc.ABCMeta Metaclass for defining Abstract Base Classes (ABCs). Use this metaclass to create an ABC. An ABC can be subclassed directly, and then acts as a mix-in class. You can also register unrelated concrete classes (even built-in classes) and unrelated ABCs as “virtual subclasses” – these and their descendants will be considered subclasses of the registering ABC by the built-in issubclass() function, but the registering ABC won’t show up in their MRO (Method Resolution Order) nor w

abc.abstractclassmethod()

@abc.abstractclassmethod A subclass of the built-in classmethod(), indicating an abstract classmethod. Otherwise it is similar to abstractmethod(). This special case is deprecated, as the classmethod() decorator is now correctly identified as abstract when applied to an abstract method: class C(metaclass=ABCMeta): @classmethod @abstractmethod def my_abstract_classmethod(cls, ...): ... New in version 3.2. Deprecated since version 3.3: It is now possible to use classmet

abc.ABCMeta.__subclasshook__()

__subclasshook__(subclass) (Must be defined as a class method.) Check whether subclass is considered a subclass of this ABC. This means that you can customize the behavior of issubclass further without the need to call register() on every class you want to consider a subclass of the ABC. (This class method is called from the __subclasscheck__() method of the ABC.) This method should return True, False or NotImplemented. If it returns True, the subclass is considered a subclass of this ABC. I

abc.ABC

class abc.ABC A helper class that has ABCMeta as its metaclass. With this class, an abstract base class can be created by simply deriving from ABC, avoiding sometimes confusing metaclass usage. Note that the type of ABC is still ABCMeta, therefore inheriting from ABC requires the usual precautions regarding metaclass usage, as multiple inheritance may lead to metaclass conflicts. New in version 3.4.