Understanding this generator function

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Aug 27 06:51:19 EDT 2008


Hussein B <hubaghdadi at gmail.com> writes:

> This is an example of a generator function [using coroutine
> behaviour]:
[…]

> I'm not able to understand how this generator function is working,
> would you please me (what happens when calling next/send)?

The behaviour you're seeing was introduced in PEP 342, "Coroutines via
Enhanced Generators" <URL:http://www.python.org/dev/peps/pep-0342>,
which documents the behaviour.

Read that PEP, experiment further, and then ask any questions that you
still have after that.

-- 
 \      “Patience, n. A minor form of despair, disguised as a virtue.” |
  `\                   —Ambrose Bierce, _The Devil's Dictionary_, 1906 |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list