mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Run more inspect.rst
code snippets in CI (#112654)
This commit is contained in:
parent
a971574b73
commit
4ed46d2244
1 changed files with 37 additions and 27 deletions
|
@ -392,7 +392,11 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
|
|||
Return ``True`` if the object can be used in :keyword:`await` expression.
|
||||
|
||||
Can also be used to distinguish generator-based coroutines from regular
|
||||
generators::
|
||||
generators:
|
||||
|
||||
.. testcode::
|
||||
|
||||
import types
|
||||
|
||||
def gen():
|
||||
yield
|
||||
|
@ -409,7 +413,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
|
|||
.. function:: isasyncgenfunction(object)
|
||||
|
||||
Return ``True`` if the object is an :term:`asynchronous generator` function,
|
||||
for example::
|
||||
for example:
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> async def agen():
|
||||
... yield 1
|
||||
|
@ -985,7 +991,7 @@ function.
|
|||
For variable-keyword arguments (``**kwargs``) the default is an
|
||||
empty dict.
|
||||
|
||||
::
|
||||
.. doctest::
|
||||
|
||||
>>> def foo(a, b='ham', *args): pass
|
||||
>>> ba = inspect.signature(foo).bind('spam')
|
||||
|
@ -996,7 +1002,9 @@ function.
|
|||
.. versionadded:: 3.5
|
||||
|
||||
The :attr:`args` and :attr:`kwargs` properties can be used to invoke
|
||||
functions::
|
||||
functions:
|
||||
|
||||
.. testcode::
|
||||
|
||||
def test(a, *, b):
|
||||
...
|
||||
|
@ -1115,7 +1123,9 @@ Classes and functions
|
|||
``**`` arguments, if any) to their values from *args* and *kwds*. In case of
|
||||
invoking *func* incorrectly, i.e. whenever ``func(*args, **kwds)`` would raise
|
||||
an exception because of incompatible signature, an exception of the same type
|
||||
and the same or similar message is raised. For example::
|
||||
and the same or similar message is raised. For example:
|
||||
|
||||
.. doctest::
|
||||
|
||||
>>> from inspect import getcallargs
|
||||
>>> def f(a, b=1, *pos, **named):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue