def _create_module_and_parents(name):
 parts = name.split('.')
 parent = _create_module(parts[0])
 created_parts = [parts[0]]
 parts.pop(0)
 while parts:
  child_name = parts.pop(0)
  module = new.module(child_name)
  setattr(parent, child_name, module)
  created_parts.append(child_name)
  sys.modules['.'.join(created_parts)] = module
  parent = module

def _create_module_and_parents ( name ) : parts = name . split ( '.' ) parent = _create_module ( parts [ 0 ] ) created_parts = [ parts [ 0 ] ] parts . pop ( 0 ) while parts : child_name = parts . pop ( 0 ) module = new . module ( child_name ) setattr ( parent , child_name , module ) created_parts . append ( child_name ) sys . modules [ '.' . join ( created_parts ) ] = module parent = module
create a module .