inspect (1 Jan 2001)
index
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/inspect.py
Module Docs

Get useful information from live Python objects.
 
This module encapsulates the interface provided by the internal special
attributes (func_*, co_*, im_*, tb_*, etc.) in a friendlier fashion.
It also provides some help for examining source code and class layout.
 
Here are some of the useful functions provided by this module:
 
    ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(),
        isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(),
        isroutine() - check object types
    getmembers() - get members of an object that satisfy a given condition
 
    getfile(), getsourcefile(), getsource() - find an object's source code
    getdoc(), getcomments() - get documentation on an object
    getmodule() - determine the module that an object came from
    getclasstree() - arrange classes so as to represent their hierarchy
 
    getargspec(), getargvalues(), getcallargs() - get info about function arguments
    formatargspec(), formatargvalues() - format an argument spec
    getouterframes(), getinnerframes() - get info about frames
    currentframe() - get the current stack frame
    stack(), trace() - get info about frames on the stack or in a traceback

 
Modules
       
dis
imp
linecache
os
re
string
sys
tokenize
types

 
Classes
       
__builtin__.tuple(__builtin__.object)
ArgInfo
ArgSpec
Arguments
Attribute
ModuleInfo
Traceback
exceptions.Exception(exceptions.BaseException)
EndOfBlock
BlockFinder

 
class ArgInfo(__builtin__.tuple)
    ArgInfo(args, varargs, keywords, locals)
 
 
Method resolution order:
ArgInfo
__builtin__.tuple
__builtin__.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__getstate__(self)
Exclude the OrderedDict from pickling
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new OrderedDict which maps field names to their values
_replace(_self, **kwds)
Return a new ArgInfo object replacing specified fields with new values

Class methods defined here:
_make(cls, iterable, new=<built-in method __new__ of type object>, len=<built-in function len>) from __builtin__.type
Make a new ArgInfo object from a sequence or iterable

Static methods defined here:
__new__(_cls, args, varargs, keywords, locals)
Create new instance of ArgInfo(args, varargs, keywords, locals)

Data descriptors defined here:
__dict__
Return a new OrderedDict which maps field names to their values
args
Alias for field number 0
keywords
Alias for field number 2
locals
Alias for field number 3
varargs
Alias for field number 1

Data and other attributes defined here:
_fields = ('args', 'varargs', 'keywords', 'locals')

Methods inherited from __builtin__.tuple:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__rmul__(...)
x.__rmul__(n) <==> n*x
count(...)
T.count(value) -> integer -- return number of occurrences of value
index(...)
T.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.

 
class ArgSpec(__builtin__.tuple)
    ArgSpec(args, varargs, keywords, defaults)
 
 
Method resolution order:
ArgSpec
__builtin__.tuple
__builtin__.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__getstate__(self)
Exclude the OrderedDict from pickling
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new OrderedDict which maps field names to their values
_replace(_self, **kwds)
Return a new ArgSpec object replacing specified fields with new values

Class methods defined here:
_make(cls, iterable, new=<built-in method __new__ of type object>, len=<built-in function len>) from __builtin__.type
Make a new ArgSpec object from a sequence or iterable

Static methods defined here:
__new__(_cls, args, varargs, keywords, defaults)
Create new instance of ArgSpec(args, varargs, keywords, defaults)

Data descriptors defined here:
__dict__
Return a new OrderedDict which maps field names to their values
args
Alias for field number 0
defaults
Alias for field number 3
keywords
Alias for field number 2
varargs
Alias for field number 1

Data and other attributes defined here:
_fields = ('args', 'varargs', 'keywords', 'defaults')

Methods inherited from __builtin__.tuple:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__rmul__(...)
x.__rmul__(n) <==> n*x
count(...)
T.count(value) -> integer -- return number of occurrences of value
index(...)
T.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.

 
class Arguments(__builtin__.tuple)
    Arguments(args, varargs, keywords)
 
 
Method resolution order:
Arguments
__builtin__.tuple
__builtin__.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__getstate__(self)
Exclude the OrderedDict from pickling
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new OrderedDict which maps field names to their values
_replace(_self, **kwds)
Return a new Arguments object replacing specified fields with new values

Class methods defined here:
_make(cls, iterable, new=<built-in method __new__ of type object>, len=<built-in function len>) from __builtin__.type
Make a new Arguments object from a sequence or iterable

Static methods defined here:
__new__(_cls, args, varargs, keywords)
Create new instance of Arguments(args, varargs, keywords)

Data descriptors defined here:
__dict__
Return a new OrderedDict which maps field names to their values
args
Alias for field number 0
keywords
Alias for field number 2
varargs
Alias for field number 1

Data and other attributes defined here:
_fields = ('args', 'varargs', 'keywords')

Methods inherited from __builtin__.tuple:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__rmul__(...)
x.__rmul__(n) <==> n*x
count(...)
T.count(value) -> integer -- return number of occurrences of value
index(...)
T.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.

 
class Attribute(__builtin__.tuple)
    Attribute(name, kind, defining_class, object)
 
 
Method resolution order:
Attribute
__builtin__.tuple
__builtin__.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__getstate__(self)
Exclude the OrderedDict from pickling
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new OrderedDict which maps field names to their values
_replace(_self, **kwds)
Return a new Attribute object replacing specified fields with new values

Class methods defined here:
_make(cls, iterable, new=<built-in method __new__ of type object>, len=<built-in function len>) from __builtin__.type
Make a new Attribute object from a sequence or iterable

Static methods defined here:
__new__(_cls, name, kind, defining_class, object)
Create new instance of Attribute(name, kind, defining_class, object)

Data descriptors defined here:
__dict__
Return a new OrderedDict which maps field names to their values
defining_class
Alias for field number 2
kind
Alias for field number 1
name
Alias for field number 0
object
Alias for field number 3

Data and other attributes defined here:
_fields = ('name', 'kind', 'defining_class', 'object')

Methods inherited from __builtin__.tuple:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__rmul__(...)
x.__rmul__(n) <==> n*x
count(...)
T.count(value) -> integer -- return number of occurrences of value
index(...)
T.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.

 
class BlockFinder
    Provide a tokeneater() method to detect the end of a code block.
 
  Methods defined here:
__init__(self)
tokeneater(self, type, token, srow_scol, erow_ecol, line)

 
class EndOfBlock(exceptions.Exception)
    
Method resolution order:
EndOfBlock
exceptions.Exception
exceptions.BaseException
__builtin__.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from exceptions.Exception:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
class ModuleInfo(__builtin__.tuple)
    ModuleInfo(name, suffix, mode, module_type)
 
 
Method resolution order:
ModuleInfo
__builtin__.tuple
__builtin__.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__getstate__(self)
Exclude the OrderedDict from pickling
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new OrderedDict which maps field names to their values
_replace(_self, **kwds)
Return a new ModuleInfo object replacing specified fields with new values

Class methods defined here:
_make(cls, iterable, new=<built-in method __new__ of type object>, len=<built-in function len>) from __builtin__.type
Make a new ModuleInfo object from a sequence or iterable

Static methods defined here:
__new__(_cls, name, suffix, mode, module_type)
Create new instance of ModuleInfo(name, suffix, mode, module_type)

Data descriptors defined here:
__dict__
Return a new OrderedDict which maps field names to their values
mode
Alias for field number 2
module_type
Alias for field number 3
name
Alias for field number 0
suffix
Alias for field number 1

Data and other attributes defined here:
_fields = ('name', 'suffix', 'mode', 'module_type')

Methods inherited from __builtin__.tuple:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__rmul__(...)
x.__rmul__(n) <==> n*x
count(...)
T.count(value) -> integer -- return number of occurrences of value
index(...)
T.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.

 
class Traceback(__builtin__.tuple)
    Traceback(filename, lineno, function, code_context, index)
 
 
Method resolution order:
Traceback
__builtin__.tuple
__builtin__.object

Methods defined here:
__getnewargs__(self)
Return self as a plain tuple.  Used by copy and pickle.
__getstate__(self)
Exclude the OrderedDict from pickling
__repr__(self)
Return a nicely formatted representation string
_asdict(self)
Return a new OrderedDict which maps field names to their values
_replace(_self, **kwds)
Return a new Traceback object replacing specified fields with new values

Class methods defined here:
_make(cls, iterable, new=<built-in method __new__ of type object>, len=<built-in function len>) from __builtin__.type
Make a new Traceback object from a sequence or iterable

Static methods defined here:
__new__(_cls, filename, lineno, function, code_context, index)
Create new instance of Traceback(filename, lineno, function, code_context, index)

Data descriptors defined here:
__dict__
Return a new OrderedDict which maps field names to their values
code_context
Alias for field number 3
filename
Alias for field number 0
function
Alias for field number 2
index
Alias for field number 4
lineno
Alias for field number 1

Data and other attributes defined here:
_fields = ('filename', 'lineno', 'function', 'code_context', 'index')

Methods inherited from __builtin__.tuple:
__add__(...)
x.__add__(y) <==> x+y
__contains__(...)
x.__contains__(y) <==> y in x
__eq__(...)
x.__eq__(y) <==> x==y
__ge__(...)
x.__ge__(y) <==> x>=y
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__gt__(...)
x.__gt__(y) <==> x>y
__hash__(...)
x.__hash__() <==> hash(x)
__iter__(...)
x.__iter__() <==> iter(x)
__le__(...)
x.__le__(y) <==> x<=y
__len__(...)
x.__len__() <==> len(x)
__lt__(...)
x.__lt__(y) <==> x<y
__mul__(...)
x.__mul__(n) <==> x*n
__ne__(...)
x.__ne__(y) <==> x!=y
__rmul__(...)
x.__rmul__(n) <==> n*x
count(...)
T.count(value) -> integer -- return number of occurrences of value

 
Functions
       
classify_class_attrs(cls)
Return list of attribute-descriptor tuples.
 
For each name in dir(cls), the return list contains a 4-tuple
with these elements:
 
    0. The name (a string).
 
    1. The kind of attribute this is, one of these strings:
           'class method'    created via classmethod()
           'static method'   created via staticmethod()
           'property'        created via property()
           'method'          any other flavor of method
           'data'            not a method
 
    2. The class which defined this attribute (a class).
 
    3. The object as obtained directly from the defining class's
       __dict__, not via getattr.  This is especially important for
       data attributes:  C.data is just a data object, but
       C.__dict__['data'] may be a data descriptor with additional
       info, like a __doc__ string.
cleandoc(doc)
Clean up indentation from docstrings.
 
Any whitespace that can be uniformly removed from the second line
onwards is removed.
currentframe = _getframe(...)
_getframe([depth]) -> frameobject
 
Return a frame object from the call stack.  If optional integer depth is
given, return the frame object that many calls below the top of the stack.
If that is deeper than the call stack, ValueError is raised.  The default
for depth is zero, returning the frame at the top of the call stack.
 
This function should be used for internal and specialized
purposes only.
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.
formatargspec(args, varargs=None, varkw=None, defaults=None, formatarg=<type 'str'>, formatvarargs=<function <lambda>>, formatvarkw=<function <lambda>>, formatvalue=<function <lambda>>, join=<function joinseq>)
Format an argument spec from the 4 values returned by getargspec.
 
The first four arguments are (args, varargs, varkw, defaults).  The
other four arguments are the corresponding optional formatting functions
that are called to turn names and values into strings.  The ninth
argument is an optional function to format the sequence of arguments.
formatargvalues(args, varargs, varkw, locals, formatarg=<type 'str'>, formatvarargs=<function <lambda>>, formatvarkw=<function <lambda>>, formatvalue=<function <lambda>>, join=<function joinseq>)
Format an argument spec from the 4 values returned by getargvalues.
 
The first four arguments are (args, varargs, varkw, locals).  The
next four arguments are the corresponding optional formatting functions
that are called to turn names and values into strings.  The ninth
argument is an optional function to format the sequence of arguments.
getabsfile(object, _filename=None)
Return an absolute path to the source or compiled file for an object.
 
The idea is for each object to have a unique origin, so this routine
normalizes the result as much as possible.
getargs(co)
Get information about the arguments accepted by a code object.
 
Three things are returned: (args, varargs, varkw), where 'args' is
a list of argument names (possibly containing nested lists), and
'varargs' and 'varkw' are the names of the * and ** arguments or None.
getargspec(func)
Get the names and default values of a function's arguments.
 
tuple of four things is returned: (args, varargs, varkw, defaults).
'args' is a list of the argument names (it may contain nested lists).
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults' is an n-tuple of the default values of the last n arguments.
getargvalues(frame)
Get information about arguments passed into a particular frame.
 
tuple of four things is returned: (args, varargs, varkw, locals).
'args' is a list of the argument names (it may contain nested lists).
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'locals' is the locals dictionary of the given frame.
getblock(lines)
Extract the block of code at the top of the given list of lines.
getcallargs(func, *positional, **named)
Get the mapping of arguments to values.
 
A dict is returned, with keys the function argument names (including the
names of the * and ** arguments, if any), and values the respective bound
values from 'positional' and 'named'.
getclasstree(classes, unique=0)
Arrange the given list of classes into a hierarchy of nested lists.
 
Where a nested list appears, it contains classes derived from the class
whose entry immediately precedes the list.  Each entry is a 2-tuple
containing a class and a tuple of its base classes.  If the 'unique'
argument is true, exactly one entry appears in the returned structure
for each class in the given list.  Otherwise, classes using multiple
inheritance and their descendants will appear multiple times.
getcomments(object)
Get lines of comments immediately preceding an object's source code.
 
Returns None when source can't be found.
getdoc(object)
Get the documentation string for an object.
 
All tabs are expanded to spaces.  To clean up docstrings that are
indented to line up with blocks of code, any whitespace than can be
uniformly removed from the second line onwards is removed.
getfile(object)
Work out which source or compiled file an object was defined in.
getframeinfo(frame, context=1)
Get information about a frame or traceback object.
 
tuple of five things is returned: the filename, the line number of
the current line, the function name, a list of lines of context from
the source code, and the index of the current line within that list.
The optional second argument specifies the number of lines of context
to return, which are centered around the current line.
getinnerframes(tb, context=1)
Get a list of records for a traceback's frame and all lower frames.
 
Each record contains a frame object, filename, line number, function
name, a list of lines of context, and index within the context.
getlineno(frame)
Get the line number from a frame object, allowing for optimization.
getmembers(object, predicate=None)
Return all members of an object as (name, value) pairs sorted by name.
Optionally, only return members that satisfy a given predicate.
getmodule(object, _filename=None)
Return the module an object was defined in, or None if not found.
getmoduleinfo(path)
Get the module name, suffix, mode, and module type for a given file.
getmodulename(path)
Return the module name for a given file, or None.
getmro(cls)
Return tuple of base classes (including cls) in method resolution order.
getouterframes(frame, context=1)
Get a list of records for a frame and all higher (calling) frames.
 
Each record contains a frame object, filename, line number, function
name, a list of lines of context, and index within the context.
getsource(object)
Return the text of the source code for an object.
 
The argument may be a module, class, method, function, traceback, frame,
or code object.  The source code is returned as a single string.  An
IOError is raised if the source code cannot be retrieved.
getsourcefile(object)
Return the filename that can be used to locate an object's source.
Return None if no way can be identified to get the source.
getsourcelines(object)
Return a list of source lines 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 the lines
corresponding to the object and the line number indicates where in the
original source file the first line of code was found.  An IOError is
raised if the source code cannot be retrieved.
indentsize(line)
Return the indent size, in spaces, at the start of a line of text.
isabstract(object)
Return true if the object is an abstract base class (ABC).
isbuiltin(object)
Return true if the object is a built-in function or method.
 
Built-in functions and methods provide these attributes:
    __doc__         documentation string
    __name__        original name of this function or method
    __self__        instance to which a method is bound, or None
isclass(object)
Return true if the object is a class.
 
Class objects provide these attributes:
    __doc__         documentation string
    __module__      name of module in which this class was defined
iscode(object)
Return true if the object is a code object.
 
Code objects provide these attributes:
    co_argcount     number of arguments (not including * or ** args)
    co_code         string of raw compiled bytecode
    co_consts       tuple of constants used in the bytecode
    co_filename     name of file in which this code object was created
    co_firstlineno  number of first line in Python source code
    co_flags        bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg
    co_lnotab       encoded mapping of line numbers to bytecode indices
    co_name         name with which this code object was defined
    co_names        tuple of names of local variables
    co_nlocals      number of local variables
    co_stacksize    virtual machine stack space required
    co_varnames     tuple of names of arguments and local variables
isdatadescriptor(object)
Return true if the object is a data descriptor.
 
Data descriptors have both a __get__ and a __set__ attribute.  Examples are
properties (defined in Python) and getsets and members (defined in C).
Typically, data descriptors will also have __name__ and __doc__ attributes
(properties, getsets, and members have both of these attributes), but this
is not guaranteed.
isframe(object)
Return true if the object is a frame object.
 
Frame objects provide these attributes:
    f_back          next outer frame object (this frame's caller)
    f_builtins      built-in namespace seen by this frame
    f_code          code object being executed in this frame
    f_exc_traceback traceback if raised in this frame, or None
    f_exc_type      exception type if raised in this frame, or None
    f_exc_value     exception value if raised in this frame, or None
    f_globals       global namespace seen by this frame
    f_lasti         index of last attempted instruction in bytecode
    f_lineno        current line number in Python source code
    f_locals        local namespace seen by this frame
    f_restricted    0 or 1 if frame is in restricted execution mode
    f_trace         tracing function for this frame, or None
isfunction(object)
Return true if the object is a user-defined function.
 
Function objects provide these attributes:
    __doc__         documentation string
    __name__        name with which this function was defined
    func_code       code object containing compiled function bytecode
    func_defaults   tuple of any default values for arguments
    func_doc        (same as __doc__)
    func_globals    global namespace in which this function was defined
    func_name       (same as __name__)
isgenerator(object)
Return true if the object is a generator.
 
Generator objects provide these attributes:
    __iter__        defined to support iteration over container
    close           raises a new GeneratorExit exception inside the
                    generator to terminate the iteration
    gi_code         code object
    gi_frame        frame object or possibly None once the generator has
                    been exhausted
    gi_running      set to 1 when generator is executing, 0 otherwise
    next            return the next item from the container
    send            resumes the generator and "sends" a value that becomes
                    the result of the current yield-expression
    throw           used to raise an exception inside the generator
isgeneratorfunction(object)
Return true if the object is a user-defined generator function.
 
Generator function objects provides same attributes as functions.
 
See help(isfunction) for attributes listing.
isgetsetdescriptor(object)
Return true if the object is a getset descriptor.
 
getset descriptors are specialized descriptors defined in extension
modules.
ismemberdescriptor(object)
Return true if the object is a member descriptor.
 
Member descriptors are specialized descriptors defined in extension
modules.
ismethod(object)
Return true if the object is an instance method.
 
Instance method objects provide these attributes:
    __doc__         documentation string
    __name__        name with which this method was defined
    im_class        class object in which this method belongs
    im_func         function object containing implementation of method
    im_self         instance to which this method is bound, or None
ismethoddescriptor(object)
Return true if the object is a method descriptor.
 
But not if ismethod() or isclass() or isfunction() are true.
 
This is new in Python 2.2, and, for example, is true of int.__add__.
An object passing this test has a __get__ attribute but not a __set__
attribute, but beyond that the set of attributes varies.  __name__ is
usually sensible, and __doc__ often is.
 
Methods implemented via descriptors that also pass one of the other
tests return false from the ismethoddescriptor() test, simply because
the other tests promise more -- you can, e.g., count on having the
im_func attribute (etc) when an object passes ismethod().
ismodule(object)
Return true if the object is a module.
 
Module objects provide these attributes:
    __doc__         documentation string
    __file__        filename (missing for built-in modules)
isroutine(object)
Return true if the object is any kind of function or method.
istraceback(object)
Return true if the object is a traceback.
 
Traceback objects provide these attributes:
    tb_frame        frame object at this level
    tb_lasti        index of last attempted instruction in bytecode
    tb_lineno       current line number in Python source code
    tb_next         next inner traceback object (called by this level)
joinseq(seq)
stack(context=1)
Return a list of records for the stack above the caller's frame.
strseq(object, convert, join=<function joinseq>)
Recursively walk a sequence, stringifying each element.
trace(context=1)
Return a list of records for the stack below the current exception.
walktree(classes, children, parent)
Recursive helper function for getclasstree().

 
Data
        CO_GENERATOR = 32
CO_NESTED = 16
CO_NEWLOCALS = 2
CO_NOFREE = 64
CO_OPTIMIZED = 1
CO_VARARGS = 4
CO_VARKEYWORDS = 8
TPFLAGS_IS_ABSTRACT = 1048576
__author__ = 'Ka-Ping Yee <ping@lfw.org>'
__date__ = '1 Jan 2001'
modulesbyfile = {}

 
Author
        Ka-Ping Yee <ping@lfw.org>