PyDocs

Nav

Python Runtime Services

Signature

inspect

class (source)
  • Signature(parameters=None, *, return_annotation=Signature.empty)
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.)
Changed in 3.5
  • 3.5: Signature objects are now picklable and hashable.
Members of Signature

b

bind
Get a BoundArguments object, that maps the passed `args` and `kwargs` to the function's signature.
bind_partial
Get a BoundArguments object, that partially maps the passed `args` and `kwargs` to the function's signature.

e

empty
Marker object for Signature.empty and Parameter.empty.

f

format
Create a string representation of the Signature object.
from_callable
Constructs Signature for the given callable object.

p

parameters
An ordered mapping of parameters’ names to the corresponding Parameter objects.

r

replace
Creates a customized copy of the Signature.
return_annotation
The “return” annotation for the callable.
0 Examples
No examples for inspect/Signature.
See Also
No see-alsos for inspect/Signature
0 Notes
No notes for Signature