PEP 255: Simple Generators, Revised Posting
Tim Peters
tim.one at home.com
Tue Jun 26 00:22:40 EDT 2001
FYI, Python 2.2 will recognize that this is a generator after all:
def f():
if 0:
yield 1
A change to enable that was just checked in. Other varieties of "if 0:"
glitchlets weren't helped, though -- just yield.
Just van Rossum suggested a prettier way to spell this:
def f():
while 0:
yield 1
I think that's especially nice because, where you're prototyping code and
need a generator stub (placeholder), you can flip between "0" and "1" to get
either an empty or unbounded iterator, two extremes that are good for
testing.
More information about the Python-list
mailing list