def __ImportFrom(module_xname, xname):
"""
Import a specified name from a python module into the global namespace. This can be accomplished
programatically and inside a method or class.
@param module_xname : name of the module to load x.y.z
@param xname : symbol to import from loaded module
@return method/class : imported item from loaded module
"""
try:
module = __import__(module_xname,globals(),locals(), [xname])
except ImportError:
return None
try:
module = getattr(module,xname)
if xname:
for x in range( len(inspect.stack()) ):
inspect.currentframe(x).f_globals[xname]=module
except AttributeError as e:
module=None
return module
评论列表
文章目录