#1 m = __import__('Test') if hasattr(m, 'Test2'): c = getattr(m, 'Test2') o = c() #2 import imp m = imp.load_module('Test2', *imp.find_module('Test2')) if hasattr(m, 'Test2'): c = getattr(m, 'Test2') o = c() #3 s = 'from Test2 import Test2' exec s t = Test2()