def new_module(name):
    """
    Do all of the gruntwork associated with creating a new module.

    """
    parent = None
    if '.' in name:
        parent_name = name.rsplit('.', 1)[0]
        parent = __import__(parent_name, fromlist=[''])

    module = imp.new_module(name)
    sys.modules[name] = module
    if parent:
        setattr(parent, name.rsplit('.', 1)[1], module)
    return module
def new_module ( name ) : parent = None if '.' in name : parent_name = name . rsplit ( '.' , 1 ) [ 0 ] parent = __import__ ( parent_name , fromlist = [ '' ] ) module = imp . new_module ( name ) sys . modules [ name ] = module if parent : setattr ( parent , name . rsplit ( '.' , 1 ) [ 1 ] , module ) return module
Do all of the gruntwork associated with creating a new module.