def load_qualified_module(full_module_name, path=None):
 remaining_pieces = full_module_name.split('.')
 done_pieces = []
 file_obj = None
 while remaining_pieces:
  try:
   done_pieces.append(remaining_pieces.pop(0))
   curr_module_name = '.'.join(done_pieces)
   (file_obj, filename, description) = imp.find_module(done_pieces[(-1)], path)
   package_module = imp.load_module(curr_module_name, file_obj, filename, description)
   path = (getattr(package_module, '__path__', None) or [filename])
  finally:
   if file_obj:
    file_obj.close()
 return package_module

def load_qualified_module ( full_module_name , path = None ) : remaining_pieces = full_module_name . split ( '.' ) done_pieces = [ ] file_obj = None while remaining_pieces : try : done_pieces . append ( remaining_pieces . pop ( 0 ) ) curr_module_name = '.' . join ( done_pieces ) ( file_obj , filename , description ) = imp . find_module ( done_pieces [ ( - 1 ) ] , path ) package_module = imp . load_module ( curr_module_name , file_obj , filename , description ) path = ( getattr ( package_module , '__path__' , None ) or [ filename ] ) finally : if file_obj : file_obj . close ( ) return package_module
load a module which may be within a package .