[Python-Dev] PEP 288: Generator Attributes (original) (raw)

Tim Peters tim.one@comcast.net
Sat, 23 Nov 2002 23:48:12 -0500


[Jack Jansen]

I don't like it, there's "Magic! Magic!" written all over it. Generators have always given me that feeling (you start reading them as a function, then 20 lines down you meet a "yield" and suddenly realize you have to start reading at the top again, keeping in mind that this is a persistent stack frame),

Except you don't need to do such a thing -- "yield" is much the same as "print" this way. Both have the same effect on the stack frame: none. So if you don't find print to be confusing wrt local state, you shouldn't find yield confusing wrt local state either.

... Generators have to me always felt more "class-instance-like" than "function-like",

I exoect you'll feel more the opposite the more you use them. Heck, they're so much like functions that Guido reused "def" for them .