Creating single variable to consolidate multiple classes


I have a dictionary (dict1)


After that i created a register class to parse in the information

class register:
    def __init__(self,name): = dict1[name].get('name') = dict1[name].get('lula')

    def self_add(self):
        value = +
        print('self_add value : {}'.format(value))

and create a for loop to populate the it

for name, info in dict1.items():
    reg_class = register(name)
    vars()[]=reg_class ##work
    vars()['base_path'+'.']= reg_class ## not working

however, when i use vars()[]=reg_class it is working

>>> hex(

but when i use vars()['base_path'+'.']= reg_class it is not working

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'base_path' is not defined

How can i do that correctly?

asked on Stack Overflow May 18, 2021 by Jonathan • edited May 18, 2021 by Jonathan

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0