I was wondering if there exists a dynamic form of from in Python. Specifically because I want to use from 'project' import h
, where project is a variable and h is a particular class instantiation. I know there's modulelib's import_module()
, so I was wondering if there was something like that for from
. Or would I just have to use import_module()
and then call h from that?
Python dynamic from?
47 views Asked by Jpwang At
1
Check
__import__
:https://docs.python.org/2/library/functions.html#import
should be what you're looking for.
Which, looking at it, is not that much better than the
import_module
based solution...