I'm trying to import a module using __import__(). I need to use __import__ becuase I don't know which module I'll need before runtime.
Let's say the module I'll need is MyClass. The file tree is api/apps/myapp/my_class.py, and the class i have in my_class.py is MyClass. Now, to access the methods of MyClass what I'm doing is this:
my_class_module = __import__('api.apps.myapp.my_class')
my_class= my_class_module.MyClass()
But I'm getting this error:
'module' object has no attribute 'MyClass'
Any ideas?