Metaclasses - How to customize class behaviour#

In Python, everything is an object. Even a type of an object is an object, with a special type. These classes are called metaclasses in Python. In normal situations you don’t have to directly interact with these classes, and the suggested way of inheritance is by using the abstract base classes in dewloosh.core.abc. Likewise, if you want to customize the behaviour of a class, you can create your own metaclass by inheriting one of the classes of this module.

class dewloosh.core.meta.ABCMeta_Weak(name, bases, namespace, **kwargs)#

Standard python metaclass. It follows weak abstraction in the meaning, that it is enough to implement the abstarcts in the instance, they impose no restriction on the inherited class itself. Therefore, error only occurs at runtime.

class dewloosh.core.meta.ABCMeta_Strong(name, bases, namespace, *args, **kwargs)#

Strong Python metaclass. It follows strong abstraction in the meaning, that an abstract function of any of the base classes must be implemented or delayed with the use of another @abstractmethod decorator. Error occurs at compilation time.

class dewloosh.core.meta.ABCMeta_Safe(name, bases, namespace, *args, **kwargs)#

Python metaclass for safe inheritance. Throws a TypeError if a method tries to shadow a definition in any of the base classes.