diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-10-26 21:28:20 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-10-26 21:28:20 (GMT) |
commit | 735d31723fb348f08be8fc2677dbb26beac5394a (patch) | |
tree | abb776d8e423fdc59bdf04edbf33e44416f4637b /Doc/library/inspect.rst | |
parent | 6a65bcdf2ad258d63a8fe57862420ba403d19b4a (diff) | |
download | cpython-735d31723fb348f08be8fc2677dbb26beac5394a.zip cpython-735d31723fb348f08be8fc2677dbb26beac5394a.tar.gz cpython-735d31723fb348f08be8fc2677dbb26beac5394a.tar.bz2 |
Issue #16243: add example for inspect.formatargspec
Patch by Berker Peksag.
Diffstat (limited to 'Doc/library/inspect.rst')
-rw-r--r-- | Doc/library/inspect.rst | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 4050ab3..01bbce8 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -716,7 +716,7 @@ Classes and functions locals dictionary of the given frame. -.. function:: formatargspec(args[, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations, formatarg, formatvarargs, formatvarkw, formatvalue, formatreturns, formatannotations]) +.. function:: formatargspec(args[, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations[, formatarg, formatvarargs, formatvarkw, formatvalue, formatreturns, formatannotations]]) Format a pretty argument spec from the values returned by :func:`getargspec` or :func:`getfullargspec`. @@ -725,7 +725,14 @@ Classes and functions ``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. + is an optional function to format the sequence of arguments. For example:: + + >>> from inspect import formatargspec, getfullargspec + >>> def f(a: int, b: float): + ... pass + ... + >>> formatargspec(*getfullargspec(f)) + '(a: int, b: float)' .. function:: formatargvalues(args[, varargs, varkw, locals, formatarg, formatvarargs, formatvarkw, formatvalue]) |