Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 757 Bytes

File metadata and controls

33 lines (23 loc) · 757 Bytes

box Build Status codecov PyPI version

Box of Python Class and Object

Installation

Need Python 3.6+.

pip install box-box

Usage

import 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'
})