parameters: (object)
docstring: Return the entire source file and starting line number for an object.
  
      The argument may be a module, class, method, function, traceback, frame,
      or code object.  The source code is returned as a list of all the lines
      in the file and the line number indexes a line in that list.  An IOError
      is raised if the source code cannot be retrieved.
docstring_summary: Return the entire source file and starting line number for an object.
docstring_tokens: Return the entire source file and starting line number for an object .
function: def findsource(object):
      """Return the entire source file and starting line number for an object.
  
      The argument may be a module, class, method, function, traceback, frame,
      or code object.  The source code is returned as a list of all the lines
      in the file and the line number indexes a line in that list.  An IOError
      is raised if the source code cannot be retrieved."""
      try:
          file = open(getsourcefile(object))
      except (TypeError, IOError):
          raise IOError, 'could not get source code'
      lines = file.readlines()
      file.close()
  
      if ismodule(object):
          return lines, 0
  
      if isclass(object):
          name = object.__name__
          pat = re.compile(r'^\s*class\s*' + name + r'\b')
          for i in range(len(lines)):
              if pat.match(lines[i]): return lines, i
          else: raise IOError, 'could not find class definition'
  
      if ismethod(object):
          object = object.im_func
      if isfunction(object):
          object = object.func_code
      if istraceback(object):
          object = object.tb_frame
      if isframe(object):
          object = object.f_code
      if iscode(object):
          if not hasattr(object, 'co_firstlineno'):
              raise IOError, 'could not find function definition'
          lnum = object.co_firstlineno - 1
          pat = re.compile(r'^(\s*def\s)|(.*\slambda(:|\s))')
          while lnum > 0:
              if pat.match(lines[lnum]): break
              lnum = lnum - 1
          return lines, lnum
      raise IOError, 'could not find code object'
function_tokens: def findsource ( object ) : try : file = open ( getsourcefile ( object ) ) except ( TypeError , IOError ) : raise IOError , 'could not get source code' lines = file . readlines ( ) file . close ( ) if ismodule ( object ) : return lines , 0 if isclass ( object ) : name = object . __name__ pat = re . compile ( r'^\s*class\s*' + name + r'\b' ) for i in range ( len ( lines ) ) : if pat . match ( lines [ i ] ) : return lines , i else : raise IOError , 'could not find class definition' if ismethod ( object ) : object = object . im_func if isfunction ( object ) : object = object . func_code if istraceback ( object ) : object = object . tb_frame if isframe ( object ) : object = object . f_code if iscode ( object ) : if not hasattr ( object , 'co_firstlineno' ) : raise IOError , 'could not find function definition' lnum = object . co_firstlineno - 1 pat = re . compile ( r'^(\s*def\s)|(.*\slambda(:|\s))' ) while lnum > 0 : if pat . match ( lines [ lnum ] ) : break lnum = lnum - 1 return lines , lnum raise IOError , 'could not find code object'