summaryrefslogtreecommitdiffstats
path: root/Doc/library/types.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/types.rst')
-rw-r--r--Doc/library/types.rst38
1 files changed, 36 insertions, 2 deletions
diff --git a/Doc/library/types.rst b/Doc/library/types.rst
index abdb939..eb27846 100644
--- a/Doc/library/types.rst
+++ b/Doc/library/types.rst
@@ -86,8 +86,16 @@ Standard names are defined for the following types:
.. data:: GeneratorType
- The type of :term:`generator`-iterator objects, produced by calling a
- generator function.
+ The type of :term:`generator`-iterator objects, created by
+ generator functions.
+
+
+.. data:: CoroutineType
+
+ The type of :term:`coroutine` objects, created by
+ :keyword:`async def` functions.
+
+ .. versionadded:: 3.5
.. data:: CodeType
@@ -115,6 +123,10 @@ Standard names are defined for the following types:
The type of :term:`modules <module>`. Constructor takes the name of the
module to be created and optionally its :term:`docstring`.
+ .. note::
+ Use :func:`importlib.util.module_from_spec` to create a new module if you
+ wish to set the various import-controlled attributes.
+
.. attribute:: __doc__
The :term:`docstring` of the module. Defaults to ``None``.
@@ -267,3 +279,25 @@ Additional Utility Classes and Functions
attributes on the class with the same name (see Enum for an example).
.. versionadded:: 3.4
+
+
+Coroutine Utility Functions
+---------------------------
+
+.. function:: coroutine(gen_func)
+
+ This function transforms a :term:`generator` function into a
+ :term:`coroutine function` which returns a generator-based coroutine.
+ The generator-based coroutine is still a :term:`generator iterator`,
+ but is also considered to be a :term:`coroutine` object and is
+ :term:`awaitable`. However, it may not necessarily implement
+ the :meth:`__await__` method.
+
+ If *gen_func* is a generator function, it will be modified in-place.
+
+ If *gen_func* is not a generator function, it will be wrapped. If it
+ returns an instance of :class:`collections.abc.Generator`, the instance
+ will be wrapped in an *awaitable* proxy object. All other types
+ of objects will be returned as is.
+
+ .. versionadded:: 3.5