PEP 255: Simple Generators
Roman Suzi
rnd at onego.ru
Sat Jun 23 11:37:31 EDT 2001
On Sat, 23 Jun 2001, Roman Suzi wrote:
>Maybe we can define generators like this, for example:
>
>def f(x):
> f.is_generator = 1
> for i in x:
> yield k
Oops!
Maybe:
def f(x):
for i in x:
yield i
f.is_generator = 1
>Here we explicitely tell that we want "function" to be a generator!
>
>(If we forget to do it, then it will be equivalent to:
>
def f(x):
yield = []
for i in x:
yield.append(i)
return yield
>Sincerely yours, Roman Suzi
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Saturday, June 23, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "He's not dead, Jim, he's just metabolically challenged." _/
More information about the Python-list
mailing list