xoutil.eight.meta
- metaclass function using Python 3 syntax¶
Implements the metaclass() function using the Py3k syntax.
-
xoutil.eight.meta.
metaclass
(meta, **kwargs)¶ Define the metaclass of a class.
New in version 1.7.0.
Deprecated since version 2.0.0: Not needed in a world without Python 2.
This function allows to define the metaclass of a class equally in Python 2 and 3.
Usage:
>>> class Meta(type): ... pass >>> class Foobar(metaclass(Meta)): ... pass >>> class Spam(metaclass(Meta), dict): ... pass >>> type(Spam) is Meta True >>> Spam.__bases__ == (dict, ) True
New in version 1.5.5: The kwargs keywords arguments with support for
__prepare__
.Metaclasses are allowed to have a
__prepare__
classmethod to return the namespace into which the body of the class should be evaluated. See PEP 3115.Changed in version 1.7.1: Now are accepted atypical meta-classes, for example functions or any callable with the same arguments as those that type accepts (class name, tuple of base classes, attributes mapping).