can't import generators

Chris Liechti cliechti at gmx.net
Sat Jun 29 16:44:26 EDT 2002


aahz at pythoncraft.com (Aahz) wrote in news:afl5je$4iu$1 at panix1.panix.com:

> In article <m2hejlc060.fsf at mother.paradise.lost>,
> John Hunter  <jdhunter at nitace.bsd.uchicago.edu> wrote:
>>
>>I am having trouble working with generators.  Anyone know what might
>>cause this behavior:
>>
>>Python 2.2.1 (#1, Apr 22 2002, 21:20:54) [GCC 3.0.4] on linux2
>>Type "help", "copyright", "credits" or "license" for more information.
>>>>> from __future__ import generators
>>Traceback (most recent call last):
>>  File "<stdin>", line 1, in ?
>>ImportError: cannot import name generators
> 
> Can't do this in interactive mode.  Use a script.

?!?!? since when?

$ python
Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import generators
>>> def g(x):
...     for p in x: yield p
...
>>> [x for x in g(range(3))]
[0, 1, 2]
>>>

definetly works....

chris
-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list