Generators: section 9.10 of the python tutorial

Matteo Dell'Amico della at toglimi.linux.it
Thu May 13 15:14:24 EDT 2004


David Stockwell wrote:

> What does this error mean?  Does it mean we can't use yield in our 
> code?  Is yield a form of a 'return' ??
> 
> class9.py:71: Warning: 'yield' will become a reserved keyword in the future
>  File "class9.py", line 71
>    yield data[index]
>             ^
> SyntaxError: invalid syntax

Yes, you can use yield. It's different from "return", but I guess I 
couldn't explain it better then the tutorial. :-)
You are probably using python2.2. If you want to create generators, you 
need this line at the start of your python program:

from __future__ import generators





More information about the Python-list mailing list