NEWBIE: for statement in "dive into python" gives syntax error.

Mack gugabbe at hotmail.com
Tue Jul 23 15:58:36 EDT 2002


In <3D3DB42D.3080404 at earthlink.net>, Hans Nowak wrote:

> Mack wrote:
> 
>>>>>[elem*2 for elem in li]
>>>>
>>   File "<stdin>", line 1
>>     [elem*2 for elem in li]
>>               ^
>> is what i'm getting. Is my python too old? Is something else wrong?
>> I've just cut and pasted from the tutorial into python ide.
> 
> That's a list comprehension, which wasn't available in 1.5.2. I think it
> first appeared in 2.0. Upgrading to a more recent Python version should
> fix this.
 
Thanks. I just checked out the doc Whats new in 2.0 and found it. I
didn't think my redhat 7.1 was that old. I'll just upgrade then.



More information about the Python-list mailing list