def METHOD_NAME(module_name,module_script,parent_dict=None):
    """ Dynamically defines a python module. """
    if module_name in sys.modules:
        module = sys.modules[module_name]
    else:
        # create a new module
        module = imp.new_module(module_name)
        sys.modules[module_name] = module
        module.__file__ = "<%s>" % module_name
        module.__loader = None
    exec(module_script,module.__dict__,module.__dict__)
    if not parent_dict is None:
        parent_dict[module_name] = __import__(module_name)
    return module