PEP 255: Simple Generators
Rainer Deyke
root at rainerdeyke.com
Tue Jun 19 14:30:17 EDT 2001
"Neil Schemenauer" <nas at python.ca> wrote in message
news:mailman.992973455.16313.python-list at python.org...
> Rainer Deyke wrote:
> > def f():
> > return
> > yield 'Never reached.'
> >
> >
> > Is this function a generator? Yes, but only if nobody removes the
seemingly
> > redundant 'yield' statement.
>
> def f():
> return x
> x = 1
>
> Is "x" a local variable? Most of your arguments apply to local
> variables as well.
Not really. Using a local variable before it is assigned is just plain
wrong, whereas returning an empty iterator from a generator is likely to
become a common idiom.
--
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