I want to instantiate a class based on a string value but it's not working. The parser object below is a dict, in the example let's say we have one called foo and here parser['name'] is 'foo':
obj = parser['name']()
Fails, yielding TypeError: 'str' object is not callable. But, since I have:
And if I do obj = foo() it works fine and creates the correct object. Also, calling obj = type(parser['name'])() doesn't work.
Can anyone tell me how to resolve this issue?