ClassBuilder¶
-
class
mlfarm.core.ClassBuilder(_class, args)[source]¶ The instance of this class is callable with or without arguments and the call will create an instance of the python class identifier passed to the constructor.
Parameters: - _class (str) – A python class identifier, e.g. mlfarm.core.ClassBuilder
- args (dict | list | object | None) – Arguments for the constructor of _class. If None, the default constructor in called.
Returns: A callable object that returns the instance of the class with the arguments provided.
Return type: As an example we will be using the following class:
>>> class A: ... def __init__(self, a): ... self.a = a ... >>> a = A(1) >>> a.a 1 >>> cb = ClassBuilder("__main__.A", {"a": 2}) >>> cb().a 2 >>> cb() == cb() False