What's the best approach to execute the following using __import__
so that I may dynamically specify the module?
from module import *
What's the best approach to execute the following using __import__
so that I may dynamically specify the module?
from module import *
__import__()
never adds anything to the local scope. You will have to go through the returned module, accessing its attributes as desired.It's the same as a normal from-import call, you just pass it a list containing
'*'
for thefromlist
:The only way I found: