def import_module_from_name(modname):
if True:<EOL><INDENT>import importlib<EOL>module = importlib.import_module(modname)<EOL><DEDENT>else:<EOL><INDENT>if '<STR_LIT:.>' in modname:<EOL><INDENT>fromlist = modname.split('<STR_LIT:.>')[-<NUM_LIT:1>]<EOL>fromlist_ = list(map(str, fromlist))  <EOL>module = __import__(modname, {}, {}, fromlist_, <NUM_LIT:0>)<EOL><DEDENT>else:<EOL><INDENT>module = __import__(modname, {}, {}, [], <NUM_LIT:0>)<EOL><DEDENT><DEDENT>return module<EOL>
Imports a module from its string name (__name__)

Args:
    modname (str):  module name

Returns:
    module: module

Example:
    >>> # test with modules that wont be imported in normal circumstances
    >>> # todo write a test where we gaurentee this
    >>> modname_list = [
    >>>     'pickletools',
    >>>     'lib2to3.fixes.fix_apply',
    >>> ]
    >>> #assert not any(m in sys.modules for m in modname_list)
    >>> modules = [import_module_from_name(modname) for modname in modname_list]
    >>> assert [m.__name__ for m in modules] == modname_list
    >>> assert all(m in sys.modules for m in modname_list)