Box of Python Class and Object
Need Python 3.6+.
pip install box-boximport box
@box.register
class CustomModule:
@classmethod
def factory(cls, config):
return cls()
# 1. load class from name
obj_class = box.load('CustomModule')
obj = obj_class()
# 2. object factory from config
obj = box.factory(config={
'type': 'CustomModule'
})