I have a class
class Foo():
def some_method():
pass
And another class in the same module:
clas
import sys
getattr(sys.modules[__name__], "Foo")
# or
globals()['Foo']
globals()[class_name]
Note that if this isn't strictly necessary, you may want to refactor your code to not use it.
You can do it with help of sys module:
import sys
def str2Class(str):
return getattr(sys.modules[__name__], str)