-
-
Notifications
You must be signed in to change notification settings - Fork 198
Expand file tree
/
Copy pathcontainer.py
More file actions
25 lines (18 loc) · 654 Bytes
/
Copy pathcontainer.py
File metadata and controls
25 lines (18 loc) · 654 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import inspect
class Container:
def __init__(self, system_data):
for component_name, component_class, component_args in system_data:
if inspect.isclass(component_class):
args = [self.__dict__[arg] for arg in component_args]
self.__dict__[component_name] = component_class(*args)
else:
self.__dict__[component_name] = component_class
class Person:
def __init__(self, name):
self.name = name
SYSTEM_DATA = (
("name", "hello world", None),
("person", Person, ("name",)),
# ('lister', MovieLister, ('finder', )),
)
c = Container(SYSTEM_DATA)