Markdown Format | JSON API | MCP Server Tool
Help on module inspect: NAME inspect - Get useful information from live Python objects. MODULE REFERENCE https://docs.python.org/3.10/library/inspect.html The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above. DESCRIPTION This module encapsulates the interface provided by the internal special attributes (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 getargvalues(), getcallargs() - get info about function arguments getfullargspec() - same, with support for Python 3 features 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 signature() - get a Signature object for the callable get_annotations() - safely compute an object's annotations CLASSES builtins.Exception(builtins.BaseException) ClassFoundException EndOfBlock builtins.object BlockFinder BoundArguments Parameter Signature builtins.tuple(builtins.object) ArgInfo ArgSpec Arguments Attribute ClosureVars FrameInfo FullArgSpec Traceback class ArgInfo(builtins.tuple) | ArgInfo(args, varargs, keywords, locals) | | ArgInfo(args, varargs, keywords, locals) | | Method resolution order: | ArgInfo | builtins.tuple | builtins.object | | Methods defined here: | | __getnewargs__(self) | Return self as a plain tuple. Used by copy and pickle. | | __repr__(self) | Return a nicely formatted representation string | | _asdict(self) | Return a new dict 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(iterable) from builtins.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: | | args | Alias for field number 0 | | varargs | Alias for field number 1 | | keywords | Alias for field number 2 | | locals | Alias for field number 3 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __match_args__ = ('args', 'varargs', 'keywords', 'locals') | | _field_defaults = {} | | _fields = ('args', 'varargs', 'keywords', 'locals') | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | index(self, value, start=0, stop=9223372036854775807, /) | Return first index of value. | | Raises ValueError if the value is not present. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.tuple: | | __class_getitem__(...) from builtins.type | See PEP 585 class ArgSpec(builtins.tuple) | ArgSpec(args, varargs, keywords, defaults) | | ArgSpec(args, varargs, keywords, defaults) | | Method resolution order: | ArgSpec | builtins.tuple | builtins.object | | Methods defined here: | | __getnewargs__(self) | Return self as a plain tuple. Used by copy and pickle. | | __repr__(self) | Return a nicely formatted representation string | | _asdict(self) | Return a new dict 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(iterable) from builtins.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: | | args | Alias for field number 0 | | varargs | Alias for field number 1 | | keywords | Alias for field number 2 | | defaults | Alias for field number 3 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __match_args__ = ('args', 'varargs', 'keywords', 'defaults') | | _field_defaults = {} | | _fields = ('args', 'varargs', 'keywords', 'defaults') | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | index(self, value, start=0, stop=9223372036854775807, /) | Return first index of value. | | Raises ValueError if the value is not present. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.tuple: | | __class_getitem__(...) from builtins.type | See PEP 585 class Arguments(builtins.tuple) | Arguments(args, varargs, varkw) | | Arguments(args, varargs, varkw) | | Method resolution order: | Arguments | builtins.tuple | builtins.object | | Methods defined here: | | __getnewargs__(self) | Return self as a plain tuple. Used by copy and pickle. | | __repr__(self) | Return a nicely formatted representation string | | _asdict(self) | Return a new dict 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(iterable) from builtins.type | Make a new Arguments object from a sequence or iterable | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(_cls, args, varargs, varkw) | Create new instance of Arguments(args, varargs, varkw) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | args | Alias for field number 0 | | varargs | Alias for field number 1 | | varkw | Alias for field number 2 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __match_args__ = ('args', 'varargs', 'varkw') | | _field_defaults = {} | | _fields = ('args', 'varargs', 'varkw') | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | index(self, value, start=0, stop=9223372036854775807, /) | Return first index of value. | | Raises ValueError if the value is not present. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.tuple: | | __class_getitem__(...) from builtins.type | See PEP 585 class Attribute(builtins.tuple) | Attribute(name, kind, defining_class, object) | | Attribute(name, kind, defining_class, object) | | Method resolution order: | Attribute | builtins.tuple | builtins.object | | Methods defined here: | | __getnewargs__(self) | Return self as a plain tuple. Used by copy and pickle. | | __repr__(self) | Return a nicely formatted representation string | | _asdict(self) | Return a new dict 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(iterable) from builtins.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: | | name | Alias for field number 0 | | kind | Alias for field number 1 | | defining_class | Alias for field number 2 | | object | Alias for field number 3 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __match_args__ = ('name', 'kind', 'defining_class', 'object') | | _field_defaults = {} | | _fields = ('name', 'kind', 'defining_class', 'object') | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | index(self, value, start=0, stop=9223372036854775807, /) | Return first index of value. | | Raises ValueError if the value is not present. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.tuple: | | __class_getitem__(...) from builtins.type | See PEP 585 class BlockFinder(builtins.object) | Provide a tokeneater() method to detect the end of a code block. | | Methods defined here: | | __init__(self) | Initialize self. See help(type(self)) for accurate signature. | | tokeneater(self, type, token, srowcol, erowcol, line) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __dict__ | dictionary for instance variables (if defined) | | __weakref__ | list of weak references to the object (if defined) class BoundArguments(builtins.object) | BoundArguments(signature, arguments) | | Result of `Signature.bind` call. Holds the mapping of arguments | to the function's parameters. | | Has the following public attributes: | | * arguments : dict | An ordered mutable mapping of parameters' names to arguments' values. | Does not contain arguments' default values. | * signature : Signature | The Signature object that created this instance. | * args : tuple | Tuple of positional arguments values. | * kwargs : dict | Dict of keyword arguments values. | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __getstate__(self) | | __init__(self, signature, arguments) | Initialize self. See help(type(self)) for accurate signature. | | __repr__(self) | Return repr(self). | | __setstate__(self, state) | | apply_defaults(self) | Set default values for missing arguments. | | For variable-positional arguments (*args) the default is an | empty tuple. | | For variable-keyword arguments (**kwargs) the default is an | empty dict. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | args | | kwargs | | signature | | ---------------------------------------------------------------------- | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | arguments | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __hash__ = None class ClassFoundException(builtins.Exception) | Method resolution order: | ClassFoundException | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from builtins.Exception: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class ClosureVars(builtins.tuple) | ClosureVars(nonlocals, globals, builtins, unbound) | | ClosureVars(nonlocals, globals, builtins, unbound) | | Method resolution order: | ClosureVars | builtins.tuple | builtins.object | | Methods defined here: | | __getnewargs__(self) | Return self as a plain tuple. Used by copy and pickle. | | __repr__(self) | Return a nicely formatted representation string | | _asdict(self) | Return a new dict which maps field names to their values. | | _replace(self, /, **kwds) | Return a new ClosureVars object replacing specified fields with new values | | ---------------------------------------------------------------------- | Class methods defined here: | | _make(iterable) from builtins.type | Make a new ClosureVars object from a sequence or iterable | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(_cls, nonlocals, globals, builtins, unbound) | Create new instance of ClosureVars(nonlocals, globals, builtins, unbound) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | nonlocals | Alias for field number 0 | | globals | Alias for field number 1 | | builtins | Alias for field number 2 | | unbound | Alias for field number 3 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __match_args__ = ('nonlocals', 'globals', 'builtins', 'unbound') | | _field_defaults = {} | | _fields = ('nonlocals', 'globals', 'builtins', 'unbound') | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | index(self, value, start=0, stop=9223372036854775807, /) | Return first index of value. | | Raises ValueError if the value is not present. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.tuple: | | __class_getitem__(...) from builtins.type | See PEP 585 class EndOfBlock(builtins.Exception) | Method resolution order: | EndOfBlock | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object (if defined) | | ---------------------------------------------------------------------- | Methods inherited from builtins.Exception: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.Exception: | | __new__(*args, **kwargs) from builtins.type | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __delattr__(self, name, /) | Implement delattr(self, name). | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setattr__(self, name, value, /) | Implement setattr(self, name, value). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args class FrameInfo(builtins.tuple) | FrameInfo(frame, filename, lineno, function, code_context, index) | | FrameInfo(frame, filename, lineno, function, code_context, index) | | Method resolution order: | FrameInfo | builtins.tuple | builtins.object | | Methods defined here: | | __getnewargs__(self) | Return self as a plain tuple. Used by copy and pickle. | | __repr__(self) | Return a nicely formatted representation string | | _asdict(self) | Return a new dict which maps field names to their values. | | _replace(self, /, **kwds) | Return a new FrameInfo object replacing specified fields with new values | | ---------------------------------------------------------------------- | Class methods defined here: | | _make(iterable) from builtins.type | Make a new FrameInfo object from a sequence or iterable | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(_cls, frame, filename, lineno, function, code_context, index) | Create new instance of FrameInfo(frame, filename, lineno, function, code_context, index) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | frame | Alias for field number 0 | | filename | Alias for field number 1 | | lineno | Alias for field number 2 | | function | Alias for field number 3 | | code_context | Alias for field number 4 | | index | Alias for field number 5 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __match_args__ = ('frame', 'filename', 'lineno', 'function', 'code_con... | | _field_defaults = {} | | _fields = ('frame', 'filename', 'lineno', 'function', 'code_context', ... | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.tuple: | | __class_getitem__(...) from builtins.type | See PEP 585 class FullArgSpec(builtins.tuple) | FullArgSpec(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations) | | FullArgSpec(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations) | | Method resolution order: | FullArgSpec | builtins.tuple | builtins.object | | Methods defined here: | | __getnewargs__(self) | Return self as a plain tuple. Used by copy and pickle. | | __repr__(self) | Return a nicely formatted representation string | | _asdict(self) | Return a new dict which maps field names to their values. | | _replace(self, /, **kwds) | Return a new FullArgSpec object replacing specified fields with new values | | ---------------------------------------------------------------------- | Class methods defined here: | | _make(iterable) from builtins.type | Make a new FullArgSpec object from a sequence or iterable | | ---------------------------------------------------------------------- | Static methods defined here: | | __new__(_cls, args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations) | Create new instance of FullArgSpec(args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations) | | ---------------------------------------------------------------------- | Data descriptors defined here: | | args | Alias for field number 0 | | varargs | Alias for field number 1 | | varkw | Alias for field number 2 | | defaults | Alias for field number 3 | | kwonlyargs | Alias for field number 4 | | kwonlydefaults | Alias for field number 5 | | annotations | Alias for field number 6 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __match_args__ = ('args', 'varargs', 'varkw', 'defaults', 'kwonlyargs'... | | _field_defaults = {} | | _fields = ('args', 'varargs', 'varkw', 'defaults', 'kwonlyargs', 'kwon... | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | index(self, value, start=0, stop=9223372036854775807, /) | Return first index of value. | | Raises ValueError if the value is not present. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.tuple: | | __class_getitem__(...) from builtins.type | See PEP 585 class Parameter(builtins.object) | Parameter(name, kind, *, default, annotation) | | Represents a parameter in a function signature. | | Has the following public attributes: | | * name : str | The name of the parameter as a string. | * default : object | The default value for the parameter if specified. If the | parameter has no default value, this attribute is set to | `Parameter.empty`. | * annotation | The annotation for the parameter if specified. If the | parameter has no annotation, this attribute is set to | `Parameter.empty`. | * kind : str | Describes how argument values are bound to the parameter. | Possible values: `Parameter.POSITIONAL_ONLY`, | `Parameter.POSITIONAL_OR_KEYWORD`, `Parameter.VAR_POSITIONAL`, | `Parameter.KEYWORD_ONLY`, `Parameter.VAR_KEYWORD`. | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, name, kind, *, default, annotation) | Initialize self. See help(type(self)) for accurate signature. | | __reduce__(self) | Helper for pickle. | | __repr__(self) | Return repr(self). | | __setstate__(self, state) | | __str__(self) | Return str(self). | | replace(self, *, name=<class 'inspect._void'>, kind=<class 'inspect._void'>, annotation=<class 'inspect._void'>, default=<class 'inspect._void'>) | Creates a customized copy of the Parameter. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | annotation | | default | | kind | | name | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | KEYWORD_ONLY = <_ParameterKind.KEYWORD_ONLY: 3> | | POSITIONAL_ONLY = <_ParameterKind.POSITIONAL_ONLY: 0> | | POSITIONAL_OR_KEYWORD = <_ParameterKind.POSITIONAL_OR_KEYWORD: 1> | | VAR_KEYWORD = <_ParameterKind.VAR_KEYWORD: 4> | | VAR_POSITIONAL = <_ParameterKind.VAR_POSITIONAL: 2> | | empty = <class 'inspect._empty'> | Marker object for Signature.empty and Parameter.empty. class Signature(builtins.object) | Signature(parameters=None, *, return_annotation, __validate_parameters__=True) | | A Signature object represents the overall signature of a function. | It stores a Parameter object for each parameter accepted by the | function, as well as information specific to the function itself. | | A Signature object has the following public attributes and methods: | | * parameters : OrderedDict | An ordered mapping of parameters' names to the corresponding | Parameter objects (keyword-only arguments are in the same order | as listed in `code.co_varnames`). | * return_annotation : object | The annotation for the return type of the function if specified. | If the function has no annotation for its return type, this | attribute is set to `Signature.empty`. | * bind(*args, **kwargs) -> BoundArguments | Creates a mapping from positional and keyword arguments to | parameters. | * bind_partial(*args, **kwargs) -> BoundArguments | Creates a partial mapping from positional and keyword arguments | to parameters (simulating 'functools.partial' behavior.) | | Methods defined here: | | __eq__(self, other) | Return self==value. | | __hash__(self) | Return hash(self). | | __init__(self, parameters=None, *, return_annotation, __validate_parameters__=True) | Constructs Signature from the given list of Parameter | objects and 'return_annotation'. All arguments are optional. | | __reduce__(self) | Helper for pickle. | | __repr__(self) | Return repr(self). | | __setstate__(self, state) | | __str__(self) | Return str(self). | | bind(self, /, *args, **kwargs) | Get a BoundArguments object, that maps the passed `args` | and `kwargs` to the function's signature. Raises `TypeError` | if the passed arguments can not be bound. | | bind_partial(self, /, *args, **kwargs) | Get a BoundArguments object, that partially maps the | passed `args` and `kwargs` to the function's signature. | Raises `TypeError` if the passed arguments can not be bound. | | replace(self, *, parameters=<class 'inspect._void'>, return_annotation=<class 'inspect._void'>) | Creates a customized copy of the Signature. | Pass 'parameters' and/or 'return_annotation' arguments | to override them in the new copy. | | ---------------------------------------------------------------------- | Class methods defined here: | | from_builtin(func) from builtins.type | Constructs Signature for the given builtin function. | | Deprecated since Python 3.5, use `Signature.from_callable()`. | | from_callable(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False) from builtins.type | Constructs Signature for the given callable object. | | from_function(func) from builtins.type | Constructs Signature for the given python function. | | Deprecated since Python 3.5, use `Signature.from_callable()`. | | ---------------------------------------------------------------------- | Readonly properties defined here: | | parameters | | return_annotation | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | empty = <class 'inspect._empty'> | Marker object for Signature.empty and Parameter.empty. class Traceback(builtins.tuple) | Traceback(filename, lineno, function, code_context, index) | | Traceback(filename, lineno, function, code_context, index) | | Method resolution order: | Traceback | builtins.tuple | builtins.object | | Methods defined here: | | __getnewargs__(self) | Return self as a plain tuple. Used by copy and pickle. | | __repr__(self) | Return a nicely formatted representation string | | _asdict(self) | Return a new dict 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(iterable) from builtins.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: | | filename | Alias for field number 0 | | lineno | Alias for field number 1 | | function | Alias for field number 2 | | code_context | Alias for field number 3 | | index | Alias for field number 4 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __match_args__ = ('filename', 'lineno', 'function', 'code_context', 'i... | | _field_defaults = {} | | _fields = ('filename', 'lineno', 'function', 'code_context', 'index') | | ---------------------------------------------------------------------- | Methods inherited from builtins.tuple: | | __add__(self, value, /) | Return self+value. | | __contains__(self, key, /) | Return key in self. | | __eq__(self, value, /) | Return self==value. | | __ge__(self, value, /) | Return self>=value. | | __getattribute__(self, name, /) | Return getattr(self, name). | | __getitem__(self, key, /) | Return self[key]. | | __gt__(self, value, /) | Return self>value. | | __hash__(self, /) | Return hash(self). | | __iter__(self, /) | Implement iter(self). | | __le__(self, value, /) | Return self<=value. | | __len__(self, /) | Return len(self). | | __lt__(self, value, /) | Return self<value. | | __mul__(self, value, /) | Return self*value. | | __ne__(self, value, /) | Return self!=value. | | __rmul__(self, value, /) | Return value*self. | | count(self, value, /) | Return number of occurrences of value. | | ---------------------------------------------------------------------- | Class methods inherited from builtins.tuple: | | __class_getitem__(...) from builtins.type | See PEP 585 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 or descriptor 'data' not a method 2. The class which defined this attribute (a class). 3. The object as obtained by calling getattr; if this fails, or if the resulting object does not live anywhere in the class' mro (including metaclasses) then the object is looked up in the defining class's dict (found by walking the mro). If one of the items in dir(cls) is stored in the metaclass it will now be discovered and not have None be listed as the class in which it was defined. Any items whose home class cannot be discovered are skipped. cleandoc(doc) Clean up indentation from docstrings. Any whitespace that can be uniformly removed from the second line onwards is removed. currentframe() Return the frame of the caller or None if this is not possible. 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 OSError is raised if the source code cannot be retrieved. formatannotation(annotation, base_module=None) formatannotationrelativeto(object) formatargspec(args, varargs=None, varkw=None, defaults=None, kwonlyargs=(), kwonlydefaults={}, annotations={}, formatarg=<class 'str'>, formatvarargs=<function <lambda> at 0x7f106c59aef0>, formatvarkw=<function <lambda> at 0x7f106c59af80>, formatvalue=<function <lambda> at 0x7f106c59b010>, formatreturns=<function <lambda> at 0x7f106c59b0a0>, formatannotation=<function formatannotation at 0x7f106c59add0>) Format an argument spec from the values returned by getfullargspec. The first seven arguments are (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). The other five arguments are the corresponding optional formatting functions that are called to turn names and values into strings. The last argument is an optional function to format the sequence of arguments. Deprecated since Python 3.5: use the `signature` function and `Signature` objects. formatargvalues(args, varargs, varkw, locals, formatarg=<class 'str'>, formatvarargs=<function <lambda> at 0x7f106c59b250>, formatvarkw=<function <lambda> at 0x7f106c59b2e0>, formatvalue=<function <lambda> at 0x7f106c59b370>) 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. get_annotations(obj, *, globals=None, locals=None, eval_str=False) Compute the annotations dict for an object. obj may be a callable, class, or module. Passing in an object of any other type raises TypeError. Returns a dict. get_annotations() returns a new dict every time it's called; calling it twice on the same object will return two different but equivalent dicts. This function handles several details for you: * If eval_str is true, values of type str will be un-stringized using eval(). This is intended for use with stringized annotations ("from __future__ import annotations"). * If obj doesn't have an annotations dict, returns an empty dict. (Functions and methods always have an annotations dict; classes, modules, and other types of callables may not.) * Ignores inherited annotations on classes. If a class doesn't have its own annotations dict, returns an empty dict. * All accesses to object members and dict values are done using getattr() and dict.get() for safety. * Always, always, always returns a freshly-created dict. eval_str controls whether or not values of type str are replaced with the result of calling eval() on those values: * If eval_str is true, eval() is called on values of type str. * If eval_str is false (the default), values of type str are unchanged. globals and locals are passed in to eval(); see the documentation for eval() for more information. If either globals or locals is None, this function may replace that value with a context-specific default, contingent on type(obj): * If obj is a module, globals defaults to obj.__dict__. * If obj is a class, globals defaults to sys.modules[obj.__module__].__dict__ and locals defaults to the obj class namespace. * If obj is a callable, globals defaults to obj.__globals__, although if obj is a wrapped function (using functools.update_wrapper()) it is first unwrapped. 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 the list of argument names. Keyword-only arguments are appended. 'varargs' and 'varkw' are the names of the * and ** arguments or None. getargspec(func) Get the names and default values of a function's parameters. A tuple of four things is returned: (args, varargs, keywords, defaults). 'args' is a list of the argument names, including keyword-only argument names. 'varargs' and 'keywords' are the names of the * and ** parameters or None. 'defaults' is an n-tuple of the default values of the last n parameters. This function is deprecated, as it does not support annotations or keyword-only parameters and will raise ValueError if either is present on the supplied callable. For a more structured introspection API, use inspect.signature() instead. Alternatively, use getfullargspec() for an API with a similar namedtuple based interface, but full support for annotations and keyword-only parameters. Deprecated since Python 3.5, use `inspect.getfullargspec()`. getargvalues(frame) Get information about arguments passed into a particular frame. A tuple of four things is returned: (args, varargs, varkw, locals). 'args' is a list of the argument names. 'varargs' and 'varkw' are the names of the * and ** arguments or None. 'locals' is the locals dictionary of the given frame. getattr_static(obj, attr, default=<object object at 0x7f106c96c890>) Retrieve attributes without triggering dynamic lookup via the descriptor protocol, __getattr__ or __getattribute__. Note: this function may not be able to retrieve all attributes that getattr can fetch (like dynamically created attributes) and may find attributes that getattr can't (like descriptors that raise AttributeError). It can also return descriptor objects instead of instance members in some cases. See the documentation for details. 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=False) 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. getclosurevars(func) Get the mapping of free variables to their current values. Returns a named tuple of dicts mapping the current nonlocal, global and builtin references as seen by the body of the function. A final set of unbound names that could not be resolved is also provided. getcomments(object) Get lines of comments immediately preceding an object's source code. Returns None when source can't be found. getcoroutinelocals(coroutine) Get the mapping of coroutine local variables to their current values. A dict is returned, with the keys the local variable names and values the bound values. getcoroutinestate(coroutine) Get current state of a coroutine object. Possible states are: CORO_CREATED: Waiting to start execution. CORO_RUNNING: Currently being executed by the interpreter. CORO_SUSPENDED: Currently suspended at an await expression. CORO_CLOSED: Execution has completed. 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. A 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. getfullargspec(func) Get the names and default values of a callable object's parameters. A tuple of seven things is returned: (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). 'args' is a list of the parameter names. 'varargs' and 'varkw' are the names of the * and ** parameters or None. 'defaults' is an n-tuple of the default values of the last n parameters. 'kwonlyargs' is a list of keyword-only parameter names. 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults. 'annotations' is a dictionary mapping parameter names to annotations. Notable differences from inspect.signature(): - the "self" parameter is always reported, even for bound methods - wrapper chains defined by __wrapped__ *not* unwrapped automatically getgeneratorlocals(generator) Get the mapping of generator local variables to their current values. A dict is returned, with the keys the local variable names and values the bound values. getgeneratorstate(generator) Get current state of a generator-iterator. Possible states are: GEN_CREATED: Waiting to start execution. GEN_RUNNING: Currently being executed by the interpreter. GEN_SUSPENDED: Currently suspended at a yield expression. GEN_CLOSED: Execution has completed. 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. 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 OSError 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 OSError 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). isasyncgen(object) Return true if the object is an asynchronous generator. isasyncgenfunction(obj) Return true if the object is an asynchronous generator function. Asynchronous generator functions are defined with "async def" syntax and have "yield" expressions in their body. isawaitable(object) Return true if object can be passed to an ``await`` expression. 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 *, ** args or keyword only arguments) co_code string of raw compiled bytecode co_cellvars tuple of names of cell variables 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 | 16=nested | 32=generator | 64=nofree | 128=coroutine | 256=iterable_coroutine | 512=async_generator co_freevars tuple of names of free variables co_posonlyargcount number of positional only arguments co_kwonlyargcount number of keyword only arguments (not including ** 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 other than arguments and function locals co_nlocals number of local variables co_stacksize virtual machine stack space required co_varnames tuple of names of arguments and local variables iscoroutine(object) Return true if the object is a coroutine. iscoroutinefunction(obj) Return true if the object is a coroutine function. Coroutine functions are defined with "async def" syntax. isdatadescriptor(object) Return true if the object is a data descriptor. Data descriptors have a __set__ or a __delete__ 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_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_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 __code__ code object containing compiled function bytecode __defaults__ tuple of any default values for arguments __globals__ global namespace in which this function was defined __annotations__ dict of parameter annotations __kwdefaults__ dict of keyword only parameters with defaults 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(obj) Return true if the object is a user-defined generator function. Generator function objects provide the same attributes as functions. See help(isfunction) for a list of attributes. 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 __func__ function object containing implementation of method __self__ instance to which this method is bound 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 __func__ attribute (etc) when an object passes ismethod(). ismodule(object) Return true if the object is a module. Module objects provide these attributes: __cached__ pathname to byte compiled file __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) signature(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False) Get a signature object for the passed callable. stack(context=1) Return a list of records for the stack above the caller's frame. trace(context=1) Return a list of records for the stack below the current exception. unwrap(func, *, stop=None) Get the object wrapped by *func*. Follows the chain of :attr:`__wrapped__` attributes returning the last object in the chain. *stop* is an optional callback accepting an object in the wrapper chain as its sole argument that allows the unwrapping to be terminated early if the callback returns a true value. If the callback never returns a true value, the last object in the chain is returned as usual. For example, :func:`signature` uses this to stop unwrapping if any object in the chain has a ``__signature__`` attribute defined. :exc:`ValueError` is raised if a cycle is encountered. walktree(classes, children, parent) Recursive helper function for getclasstree(). DATA CORO_CLOSED = 'CORO_CLOSED' CORO_CREATED = 'CORO_CREATED' CORO_RUNNING = 'CORO_RUNNING' CORO_SUSPENDED = 'CORO_SUSPENDED' CO_ASYNC_GENERATOR = 512 CO_COROUTINE = 128 CO_GENERATOR = 32 CO_ITERABLE_COROUTINE = 256 CO_NESTED = 16 CO_NEWLOCALS = 2 CO_NOFREE = 64 CO_OPTIMIZED = 1 CO_VARARGS = 4 CO_VARKEYWORDS = 8 GEN_CLOSED = 'GEN_CLOSED' GEN_CREATED = 'GEN_CREATED' GEN_RUNNING = 'GEN_RUNNING' GEN_SUSPENDED = 'GEN_SUSPENDED' TPFLAGS_IS_ABSTRACT = 1048576 k = 512 mod_dict = {'ArgInfo': <class 'inspect.ArgInfo'>, 'ArgSpec': <class 'i... modulesbyfile = {} v = 'ASYNC_GENERATOR' AUTHOR ('Ka-Ping Yee <ping AT lfw.org>', 'Yury Selivanov <yselivanov AT sprymix.com>') FILE /usr/lib/python3.10/inspect.py
Generated by phpMan Author: Che Dong Under GNU General Public License
2026-06-02 05:14 @216.73.216.198 CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)