def get_module_name(module_obj):
if not is_object_module(module_obj):<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>name = module_obj.__name__<EOL>msg = "<STR_LIT>"<EOL>if name not in sys.modules:<EOL><INDENT>raise RuntimeError(msg.format(name=name))<EOL><DEDENT>return name<EOL>
r"""
    Retrieve the module name from a module object.

    :param module_obj: Module object
    :type  module_obj: object

    :rtype: string

    :raises:
     * RuntimeError (Argument \`module_obj\` is not valid)

     * RuntimeError (Module object \`*[module_name]*\` could not be found in
       loaded modules)

    For example:

        >>> import pexdoc.pinspect
        >>> pexdoc.pinspect.get_module_name(sys.modules['pexdoc.pinspect'])
        'pexdoc.pinspect'