generators not working? python 2.2
Mark McEahern
marklists at mceahern.com
Fri Jan 11 13:10:49 EST 2002
I tried this simple example from:
http://python.sourceforge.net/peps/pep-0255.html
and it doesn't seem to work? I'm probably doing something obviously wrong.
Please help.
$ python
Python 2.2 (#1, Dec 31 2001, 15:21:18)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import generators
>>> def fib():
... a, b = 0, 1
... while 1:
... yield b
... a, b = b, a + b
...
>>> for i in xrange(1, 10):
... print fib().next()
...
1
1
1
1
1
1
1
1
1
Thanks,
// mark
More information about the Python-list
mailing list