PEP 255: Simple Generators
Rainer Deyke
root at rainerdeyke.com
Fri Jun 22 21:13:56 EDT 2001
"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.993249814.17014.python-list at python.org...
> If you're only interested in the first 100 nanoseconds of a generator's
> life, that's true <wink>. But when you write a generator, or analyze a
> generator, or think about a generator, or step thru a generator in a
> debugger (etc), they're just resumable functions; much like class methods
> are just functions with a magical first argument. We spell class methods
> with "def" to emphasize the similarities; ditto for generators. That
> doesn't mean differences don't exist, but that the similarities are so
deep
> that harping on the differences is more distracting than helpful.
Another faulty analogy. 'def' inside a class creates a function This
function is automagically converted into an unbound method by the class
constructor. The unbound method is then automagically converted into a
bound method when accessed through an instance. Both of these conversions
are messy (especially since they are based on concrete types and therefore
non-polymorphic), but they happen after 'def' has already created a totally
normal function object.
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list
mailing list