Re[3]: [Tutor] Comparative code questions: Python vs. Rebol

Magnus Lycka magnus@thinkware.se
Fri Jan 17 06:14:05 2003


At 13:11 2003-01-17 +0300, antonmuhin =ED=E0 rambler.ru wrote:
>    [x + y for x, y reducing [1, 2, 3]]
>
>that calculates 6 ([] seems bad here, sorry). What do you think about it=
?

I think you already figured out that it's not right. You
should not use [] when you don't make a list. List
comprehension  syntax only fits when you make a list, and
I'm not really convinced that adding it to Python was a good
thing. I think it's a good thing to keep the number of concept
programmers have to learn low.

I'm not sure that

s =3D 0
for i in [1, 2, 3]:
     s +=3D i

is such a bad thing.

And I don't see that a syntax mimicing list comprehension
for reduce would be better than reduce is today. Despite my
mixed feelings about adding new and redundant concepts to
Python, I do realize than list comprehension adds some new
convenience to Python by combining map, filter and lambda in
one construct. But it is a construction for creating lists.


--=20
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se