How does one convert a string to the name of a class in Python? For example, if I have a series of related classes such as MyClass1, MyClass2, MyClassN..., how do I call the class I need if I were in a conditional assuming only the ending number of the string were to change?
Edit: All the classes are already defined. I just need a way to call them depending on the situation. The number will be coming from a GET variable so it would be nice if I can just append that number to a string.
dict. Or in your case, maybe alistglobals()dict, although that's sort of hacky. Better to just make your own dictionary to keep things cleangetattrto dynamically use a class from an imported module:getattr(module, 'MyClass{}'.format(num))