parameters: (obj)
return_statement: return module
docstring: Return the module that contains the object definition of obj.
  
      Note: Use inspect.getmodule instead.
  
      Arguments:
      obj -- python obj, generally a class or a function
  
      Examples:
      
      A function:
      >>> module = getmodule(random.choice)
      >>> module.__name__
      'random'
      >>> module is random
      1
  
      A class:
      >>> module = getmodule(random.Random)
      >>> module.__name__
      'random'
      >>> module is random
      1
  
      A class inheriting from a class in another module:
      (note: The inheriting class must define at least one function.)
      >>> class MyRandom(random.Random):
      ...     def play(self):
      ...         pass
      >>> module = getmodule(MyRandom)
      >>> if __name__ == '__main__':
      ...     name = 'rad_util'
      ... else:
      ...     name = module.__name__
      >>> name
      'rad_util'
      >>> module is sys.modules[__name__]
      1
  
      Discussion:
      This approach is slightly hackish, and won't work in various situations.
      However, this was the approach recommended by GvR, so it's as good as
      you'll get.
  
      See GvR's post in this thread:
      http://groups.google.com.au/group/comp.lang.python/browse_thread/thread/966a7bdee07e3b34/c3cab3f41ea84236?lnk=st&q=python+determine+class+module&rnum=4&hl=en#c3cab3f41ea84236
docstring_summary: Return the module that contains the object definition of obj.
docstring_tokens: Return the module that contains the object definition of obj .
function: def getmodule(obj):
      """Return the module that contains the object definition of obj.
  
      Note: Use inspect.getmodule instead.
  
      Arguments:
      obj -- python obj, generally a class or a function
  
      Examples:
      
      A function:
      >>> module = getmodule(random.choice)
      >>> module.__name__
      'random'
      >>> module is random
      1
  
      A class:
      >>> module = getmodule(random.Random)
      >>> module.__name__
      'random'
      >>> module is random
      1
  
      A class inheriting from a class in another module:
      (note: The inheriting class must define at least one function.)
      >>> class MyRandom(random.Random):
      ...     def play(self):
      ...         pass
      >>> module = getmodule(MyRandom)
      >>> if __name__ == '__main__':
      ...     name = 'rad_util'
      ... else:
      ...     name = module.__name__
      >>> name
      'rad_util'
      >>> module is sys.modules[__name__]
      1
  
      Discussion:
      This approach is slightly hackish, and won't work in various situations.
      However, this was the approach recommended by GvR, so it's as good as
      you'll get.
  
      See GvR's post in this thread:
      http://groups.google.com.au/group/comp.lang.python/browse_thread/thread/966a7bdee07e3b34/c3cab3f41ea84236?lnk=st&q=python+determine+class+module&rnum=4&hl=en#c3cab3f41ea84236
      
      """
      if hasattr(obj, 'func_globals'):
          func = obj
      else:
          # Handle classes.
          func = None
          for item in obj.__dict__.values():
              if hasattr(item, 'func_globals'):
                  func = item
                  break
          if func is None:
              raise ValueError("No functions attached to object: %r" % obj)
      module_name = func.func_globals['__name__']
      # Get module.
      module = sys.modules[module_name]
      return module
function_tokens: def getmodule ( obj ) : if hasattr ( obj , 'func_globals' ) : func = obj else : # Handle classes. func = None for item in obj . __dict__ . values ( ) : if hasattr ( item , 'func_globals' ) : func = item break if func is None : raise ValueError ( "No functions attached to object: %r" % obj ) module_name = func . func_globals [ '__name__' ] # Get module. module = sys . modules [ module_name ] return module