[Tutor] Iterators and generators for the masses

kevin parks kp87@lycos.com
Tue, 26 Feb 2002 02:40:45 +0900


A note in my Python 2.2 folder says that:

Iterators (PEP 234) and generators (PEP 255) were added.

When I ask questions on the tutor list and also this list i get answers that sometimes start:

...We can do this with Python's new generators...
...Python's new iterators make this easy...

Numerous searches turned up many complex PEPs, rewritten PEPs and 
wild drag-down knock out USENET geek fights over whether or not these were
good and should be added to Python. Nothing I could make heads or tails of.

Myself I am just getting used to seeing list comprehensions...

1> any chance that there will be tutorials on these important new features added to www.python.org?(a *real* tutorial on list comprehensions would be nice too, but at least there is documentation on them on www.python.org)

2> Anyone up to explaining them here? (hopefully in a way that someone other than Tim Peters and Guido understands! Insult me if you must -- talk to me like I am a 12 year old! Why? Because there are 12 year olds out there learning Python and those of us with the math/science/programming chops of a 12 year old who are also trying to understand this stuff).

what do they do? what can they do, what tasks do they make easier, what is the simplest possible example, what is a more complex example...etc. & co.

cheers,
kevin parks
seoul, korea

ps. I originally posted this query on c.l.p, but i probably should have posted in here instead, so i am now sending it here too. Sorry to do that, i ordinarily don't cross-post the same query.

pps. I saw in one thread there where Tim Peters writes: "I'm afraid PEPs aren't tutorials." Which pretty much sums up this question, eh!?