[Tutor] setting EOF symbol

Tim Peters tim.one@comcast.net
Sat Mar 15 23:11:02 2003


[Erik Price]
> Apart from the argument that in Python everything is an object, is a
> "generator" an object?

Yes -- everything in Python is an object <wink>.

> I mean, in other languages?  I've never seen or heard of generators
> outside of Python.  It looks like a function that maintains state.  In
> Python this is probably not too difficult since I'm guessing that the
> generator is represented by an object.  But,  speaking only of the
> "theory" of generators, how does the function maintain its state?
>
> Or do they only exist in Python.

Most of your questions are answered in the generator PEP:

    http://www.python.org/peps/pep-0255.html

Generators in Python are most like those in the Icon language:

    http://www.cs.arizona.edu/icon/

Icon is also a free language, and highly recommended if you want to exercise
your mind against a different view of the world.  Note that the definitive
book about Icon can be downloaded for free:

    http://www.cs.arizona.edu/icon/books.htm