I found this on (hmmm certainly) StackOverflow ๐
# Dynamic property for a class
class ExampleClass():
def __init__(self, argv):
for key, val in argv.items():
self.__dict__[key] = val
if __name__ == '__main__':
argv = {'intro': 'Hello World!'}
instance = ExampleClass(argv)
print instance.intro
Updates 2023/06: using __setattr__()
https://www.pythonmorsels.com/python-setattr/
ย