Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a0e41a2

Browse files
committed
Merge issue #16243: add example for inspect.formatargspec
Patch by Berker Peksag.
2 parents 28a79f8 + 735d317 commit a0e41a2

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Doc/library/inspect.rst

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ Classes and functions
716716
locals dictionary of the given frame.
717717

718718

719-
.. function:: formatargspec(args[, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations, formatarg, formatvarargs, formatvarkw, formatvalue, formatreturns, formatannotations])
719+
.. function:: formatargspec(args[, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations[, formatarg, formatvarargs, formatvarkw, formatvalue, formatreturns, formatannotations]])
720720

721721
Format a pretty argument spec from the values returned by
722722
:func:`getargspec` or :func:`getfullargspec`.
@@ -725,7 +725,14 @@ Classes and functions
725725
``defaults``, ``kwonlyargs``, ``kwonlydefaults``, ``annotations``). The
726726
other five arguments are the corresponding optional formatting functions
727727
that are called to turn names and values into strings. The last argument
728-
is an optional function to format the sequence of arguments.
728+
is an optional function to format the sequence of arguments. For example::
729+
730+
>>> from inspect import formatargspec, getfullargspec
731+
>>> def f(a: int, b: float):
732+
... pass
733+
...
734+
>>> formatargspec(*getfullargspec(f))
735+
'(a: int, b: float)'
729736

730737

731738
.. function:: formatargvalues(args[, varargs, varkw, locals, formatarg, formatvarargs, formatvarkw, formatvalue])

0 commit comments

Comments
 (0)