Say we have a python file with:
class A(object):
def say_hi(self):
print('hi, I am A')
class B(object):
def say_hi(self):
print('hi, I am B')
class F(object):
def __init__(self, name):
self.name = name
def create(self):
return ## ???
if __name__ == '__main__':
f = F('B')
b = f.create()
b.say_hi()
And I want create instance of a class with its name. What the code in F.create() should be?
globals()[self.name]()?A()if 'B' thenB().