Last active
July 25, 2018 14:12
-
-
Save mauricioabreu/55c5ae23c6c93bd56930a471a370d47e to your computer and use it in GitHub Desktop.
importlib module example
This file contains 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 | |
# Dynamic input | |
my_class = "Ping" | |
my_module = "projeto.challenges.{dynamic_module}".format(dynamic_module=my_class.lower()) | |
# Dynamic import | |
module = importlib.import_module(my_module) | |
class_i_want = getattr(module, my_class) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
funcionou com pequenas correções:
import importlib