@@ -27,7 +27,7 @@ We then commonly use it in a ``for`` loop like this:
2727
2828 It is fast and does not put a lot of pressure on memory because it
2929**generates ** the values on the fly rather then storing them in a list.
30- Now if we use ``yield `` in the above example more generally we get a
30+ Now, if we use ``yield `` in the above example, more generally, we get a
3131coroutine. Coroutines consume values which are sent to it. A very basic
3232example would be a ``grep `` alternative in Python:
3333
@@ -41,7 +41,7 @@ example would be a ``grep`` alternative in Python:
4141 print (line)
4242
4343 Wait! What does ``yield `` return? Well we have turned it into a
44- coroutine. It does not contain any value initially instead we supply it
44+ coroutine. It does not contain any value initially, instead we supply it
4545values externally. We supply values by using the ``.send() `` method.
4646Here is an example:
4747
@@ -55,13 +55,13 @@ Here is an example:
5555 search.send(" I love coroutines instead!" )
5656 # Output: I love coroutines instead!
5757
58- The sent values are accessed by yield. Why did we run ``next() ``? It is
59- done to start the coroutine. Just like ``generators `` coroutines do not
60- start the function immediately. Instead they run it in response to
61- ``__next__() `` and ``.send() `` methods. Therefore you have to run
58+ The sent values are accessed by `` yield `` . Why did we run ``next() ``? It is
59+ required in order to start the coroutine. Just like ``generators ``, coroutines do not
60+ start the function immediately. Instead they run it in response to the
61+ ``__next__() `` and ``.send() `` methods. Therefore, you have to run
6262``next() `` so that the execution advances to the ``yield `` expression.
6363
64- We can close a coroutine by calling the ``.close() `` method. Like :
64+ We can close a coroutine by calling the ``.close() `` method:
6565
6666.. code :: python
6767
0 commit comments