Reference¶
-
class
metaframe.
MetaFrame
¶ This Metaclass intercepts instance creation/initialization enabling use cases like modification of args, kwargs and/or scanning of the object post init
-
_new_pre
(*args, **kwargs)¶ Called before the object is created.
Parameters: - cls (automatic) – The class which is going to be instantiated
- args – To be passed to
__new__
for class instantiation - kwargs – To be passed to
__new__
for class instantiation
Returns: cls, args, kwargs as a tuple
The return values need not be the same that were passed
-
_new_do
(*args, **kwargs)¶ Called for object creation
Parameters: - cls (automatic) – The class which is going to be instantiated
- args – To be passed to
__new__
for class instantiation - kwargs – To be passed to
__new__
for class instantiation
Returns: obj, args, kwargs as a tuple
Note that in this method the 1st return value is no the 1st passed argument (unlike in the rest of methods) It is the created instance and not the passed class
The return values need not be the same that were passed
-
_init_pre
(obj, *args, **kwargs)¶ Called after object creation and before the object is init’ed
Parameters: - cls (-) – The class which has been instantiated
- obj (-) – The class instance which has been created
- args (-) – To be passed to
__init__
for object initialization - kwargs (-) – To be passed to
__init__
for object initialization
Returns: obj, args, kwargs as a tuple
The return values need not be the same that were passed
-
_init_do
(obj, *args, **kwargs)¶ Called for object initialization
Parameters: - cls (-) – The class which has been instantiated
- obj (-) – The class instance which has been created
- args (-) – To be passed to
__init__
for object initialization - kwargs (-) – To be passed to
__init__
for object initialization
Returns: obj, args, kwargs as a tuple
The return values need not be the same that were passed
-
_init_post
(obj, *args, **kwargs)¶ Called after object initialization
Parameters: - cls (-) – The class which has been instantiated
- obj (-) – The class instance which has been created
- args (-) – Which were passed to
__init__
for object initialization - kwargs (-) – Which were passed to
__init__
for object initialization
Returns: obj, args, kwargs as a tuple
The return values need not be the same that were passed. But modifying
args
and/orkwargs
no longer plays a role because the object has already been created and initialized
-
__call__
(*args, **kwargs)¶ Creates an initializes an instance of cls calling the pre-new, pre-init/post-init hooks with the passed/returned
args
/kwargs
-
classmethod
as_metaclass
(meta, *bases)¶ Create a base class with “this metaclass” as metaclass
Meant to be used in the definition of classes for Py2/3 syntax equality
Parameters: bases – a list of base classes to apply (object if none given)
-
-
class
metaframe.
MetaFrameBase
¶ Enables a class to MetaFrame-enabled through inheritance without having to specify/declare a metaclass