PyDocs

Nav

Python Runtime Services

signature

inspect

function (source)
  • signature(callable, *, follow_wrapped=True, globals=None, locals=None, eval_str=False, annotation_format=Format.VALUE)
Get a signature object for the passed callable.

The official docs include a CPython implementation detail for this entry.

Changed in 3.5, 3.10, 3.14
  • 3.5: The follow_wrapped parameter was added. Pass False to get a signature of callable specifically (callable.__wrapped__ will not be used to unwrap decorated callables.)
  • 3.10: The globals, locals, and eval_str parameters were added.
  • 3.14: The annotation_format parameter was added.
1 Example
>>> from inspect import signature
>>> def foo(a, *, b:int, **kwargs):
...     pass

>>> sig = signature(foo)

>>> str(sig)
'(a, *, b: int, **kwargs)'

>>> str(sig.parameters['b'])
'b: int'

>>> sig.parameters['b'].annotation
<class 'int'>
from the Python docs
See Also
No see-alsos for inspect/signature
0 Notes
No notes for signature