(obj, name)
return '__main__'
Find the module an object belong to.
Find the module an object belong to.
Find the module an object belong to .
def whichmodule(obj, name):
    """Find the module an object belong to."""
    module_name = getattr(obj, '__module__', None)
    if module_name is not None:
        return module_name
    # Protect the iteration by using a list copy of sys.modules against dynamic
    # modules that trigger imports of other modules upon calls to getattr.
    for module_name, module in sys.modules.copy().items():
        if (module_name == '__main__'
            or module_name == '__mp_main__'  # bpo-42406
            or module is None):
            continue
        try:
            if _getattribute(module, name)[0] is obj:
                return module_name
        except AttributeError:
            pass
    return '__main__'
def whichmodule ( obj , name ) : module_name = getattr ( obj , '__module__' , None ) if module_name is not None : return module_name # Protect the iteration by using a list copy of sys.modules against dynamic # modules that trigger imports of other modules upon calls to getattr. for module_name , module in sys . modules . copy ( ) . items ( ) : if ( module_name == '__main__' or module_name == '__mp_main__' # bpo-42406 or module is None ) : continue try : if _getattribute ( module , name ) [ 0 ] is obj : return module_name except AttributeError : pass return '__main__'