]> granicus.if.org Git - python/commitdiff
Issue #16243: add example for inspect.formatargspec
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Fri, 26 Oct 2012 21:28:20 +0000 (00:28 +0300)
committerAndrew Svetlov <andrew.svetlov@gmail.com>
Fri, 26 Oct 2012 21:28:20 +0000 (00:28 +0300)
Patch by Berker Peksag.

Doc/library/inspect.rst

index 4050ab3a149eb88422df364da1fd53cd61a0e84d..01bbce8f503a91ff08c69fcf6f96ba51748d89aa 100644 (file)
@@ -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])