Created
March 8, 2020 02:01
-
-
Save cicorias/ef65720f6841bcbda47046b3d81907f4 to your computer and use it in GitHub Desktop.
import python class from string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import importlib | |
module = importlib.import_module('my_package.my_module') | |
my_class = getattr(module, 'MyClass') | |
my_instance = my_class() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment