List Comprehension Syntax

Moosebumps crap at crap.crap
Sat Jul 10 21:46:25 CEST 2004

"Ville Vainio" <ville at> wrote in message
news:du7n0282lj6.fsf at
> >>>>> "Moosebumps" == Moosebumps  <crap at crap.crap> writes:
>     Moosebumps> Does anyone here find the list comprehension syntax
> ...
>     Moosebumps> I am in favor of short lines like I think Guido said
>     Moosebumps> in the style guide.  I like each line to be so simple
>     Moosebumps> as to not require any thinking reading it,
> You need to think of the total complexity involved with having several
> lines. When you see a list comprehension, you know what to expect -
> transformation and/or filtering applied to a list. Therefore, you can
> easily read and write out the beast.

Yes, I agree completely!  Note that I have no problem with the idea of LC, I
love the idea.  I am math person, I am very used to the set syntax:

S = { A(x) | Vx in 2^T }

etc., where V is the "for all", 2^ is powerset, whatever.

I am just wondering about the syntax, that's all.  Once you try to come up
with anything a little more complicated than the basic forms, they get to be
too unreadable and unformattable.

I agree it is far superior to use an expression when that is all you need,
and to only use statements when you need them!


More information about the Python-list mailing list