mixin()
Adds properties of an object as functions on UniCoreFW.
Implementation
This function dynamically adds methods to the UniCoreFW class. This is useful for adding custom functions to the library without having to modify the source code. Args: obj: An object with properties to add to UniCoreFW
Example
mixin({"triple": lambda x: x * 3, "quadruple": lambda x: x * 4})
print(UniCoreFW.triple(3)) # Output: 9
print(UniCoreFW.quadruple(2)) # Output: 8
Expected output: Adds customFunc to UniCoreFW
Source Code
def mixin(obj):
from .core import UniCoreFW
for key, func in obj.items():
if callable(func):
setattr(UniCoreFW, key, func)