[Python-checkins] peps: pep-492: Add a small example for types.coroutine

yury.selivanov python-checkins at python.org
Wed Jun 3 06:08:31 CEST 2015


https://hg.python.org/peps/rev/f72a91b9c22b
changeset:   5890:f72a91b9c22b
user:        Yury Selivanov <yselivanov at sprymix.com>
date:        Wed Jun 03 00:08:28 2015 -0400
summary:
  pep-492: Add a small example for types.coroutine

files:
  pep-0492.txt |  7 ++++++-
  1 files changed, 6 insertions(+), 1 deletions(-)


diff --git a/pep-0492.txt b/pep-0492.txt
--- a/pep-0492.txt
+++ b/pep-0492.txt
@@ -137,7 +137,12 @@
 
 A new function ``coroutine(gen)`` is added to the ``types`` module.  It
 allows interoperability between existing *generator-based coroutines*
-in asyncio and *native coroutines* introduced by this PEP.
+in asyncio and *native coroutines* introduced by this PEP::
+
+    @types.coroutine
+    def process_data(db):
+        data = yield from read_data(db)
+        ...
 
 The function applies ``CO_ITERABLE_COROUTINE`` flag to generator-
 function's code object, making it return a *coroutine* object.

-- 
Repository URL: https://hg.python.org/peps


More information about the Python-checkins mailing list