mirror of
https://github.com/python/cpython.git
synced 2025-10-03 13:45:29 +00:00
Fix documentation for inspect module to pass doctest
This commit is contained in:
parent
efcaba065e
commit
e939f383c1
1 changed files with 5 additions and 5 deletions
|
@ -494,14 +494,14 @@ Classes and functions
|
||||||
>>> from inspect import getcallargs
|
>>> from inspect import getcallargs
|
||||||
>>> def f(a, b=1, *pos, **named):
|
>>> def f(a, b=1, *pos, **named):
|
||||||
... pass
|
... pass
|
||||||
>>> getcallargs(f, 1, 2, 3)
|
>>> getcallargs(f, 1, 2, 3) == {'a': 1, 'named': {}, 'b': 2, 'pos': (3,)}
|
||||||
{'a': 1, 'named': {}, 'b': 2, 'pos': (3,)}
|
True
|
||||||
>>> getcallargs(f, a=2, x=4)
|
>>> getcallargs(f, a=2, x=4) == {'a': 2, 'named': {'x': 4}, 'b': 1, 'pos': ()}
|
||||||
{'a': 2, 'named': {'x': 4}, 'b': 1, 'pos': ()}
|
True
|
||||||
>>> getcallargs(f)
|
>>> getcallargs(f)
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
TypeError: f() takes at least 1 argument (0 given)
|
TypeError: f() missing 1 required positional argument: 'a'
|
||||||
|
|
||||||
.. versionadded:: 3.2
|
.. versionadded:: 3.2
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue