def deep_import_hook(name, globals=None, locals=None, fromlist=None, level=(-1)):
 (parent, buf) = get_parent(globals, level)
 (head, name, buf) = load_next(parent, (None if (level < 0) else parent), name, buf)
 tail = head
 while name:
  (tail, name, buf) = load_next(tail, tail, name, buf)
 if (tail is None):
  raise ValueError('Empty module name')
 if (not fromlist):
  return head
 ensure_fromlist(tail, fromlist, buf, 0)
 return tail

def deep_import_hook ( name , globals = None , locals = None , fromlist = None , level = ( - 1 ) ) : ( parent , buf ) = get_parent ( globals , level ) ( head , name , buf ) = load_next ( parent , ( None if ( level < 0 ) else parent ) , name , buf ) tail = head while name : ( tail , name , buf ) = load_next ( tail , tail , name , buf ) if ( tail is None ) : raise ValueError ( 'Empty module name' ) if ( not fromlist ) : return head ensure_fromlist ( tail , fromlist , buf , 0 ) return tail
replacement for __import__() .