List Comprehensions Enhancement

Hannah Schroeter hannah at schlund.de
Tue Sep 14 14:40:43 EDT 1999


Hello!

In article <slrn7tqhq4.cl9.wtanksle at dolphin.openprojects.net>,
William Tanksley <wtanksle at dolphin.openprojects.net> wrote:
>[... list comprehensions for python ...]

>I actually liked the verbosity a lot.  I thought it was extremely cool;
>I'd like to see this in Python, although I suspect it won't make it (it's
>a little too much like a functional language).

I won't discuss a little verbosity here and there, there are arguments
for both sides, so then.

Having only looked a bit at Python (and using some Python scripts,
like PyWiki), but not really programmed, I had still a positive
impression about the functional elements already in Python
(Lambdas, "higher order functions" like map and fold (or is that called
reduce in Py?)), so I had in fact the feeling that the Python development
seems quite open to functional elements, even if the great picture tends
more to be modular (imperative) and OO.

>[... separator between generator/predicate clauses ...]

>I agree -- my initial reaction was to put 'and' as the seperator.  Amazing
>how great minds think alike :).

>print [(i,s) for i in nums and for s in strs]

There were reasons stated both against commas (tuple syntax) and "and"
(being an operator). Perhaps some good choice should be made.

>>Nice thing, though :-)

>Oh, amazingly.  Thanks, Greg.  On a scale of one to ten I'd give it a tim.

Yes. As someone else said, List comprehensions are one of the very
great features of the languages that have them (Miranda, Haskell
for example). To count Python in this league is very neat.

Regards, Hannah.




More information about the Python-list mailing list