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.
- Params:
- cls: 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: as a tuple Return type: cls, args, kwargs 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
- Params:
- 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: as a tuple Return type: obj, args, kwargs The return values need not be the same that were passed
-
_init_post
(obj, *args, **kwargs)¶ Called after object initialization
- Params:
- 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: as a tuple Return type: obj, args, kwargs 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
-
-
class
metaframe.
MetaFrameBase
¶ Enables inheritance without having to specify/declare a metaclass