let's say I have 4 classes. I would like to create a single instance of a specific class, defined by input.
for example:
class A:
def __init__(self, arg):
self.attr = arg
...
class E:
def __init__(self, arg):
self.attr = arg
chosen_class = input('choose your class: ')
instance1 = chosen_class(self, arg)
the problem is that the class name recognized as a string and the error that shown is 'str' object has no attribute
.
my question is - How can I unwrap this string in order to use it as my class name?
from this: instance = 'A'(self)
to this: instance = A(self)
Thanks in advance!