comprehensions was Re: Switch statements again

Erik Max Francis max at alcyone.com
Thu Jan 16 18:40:37 EST 2003


Sean 'Shaleh' Perry wrote:

> comprehensions are hard on the reader until they start using them.  I
> am in
> the archives of this and -tutor stating my disklike for them for this
> reason.
> Now that I routinely use them in my own code I do like them but there
> is a
> significant penalty to the new Pythoner.

And, like any language feature, they can be abused.  It is easy to make
list comprehensions, or the use of lambda, or even while loops, that are
painfully difficult for someone other than yourself (or yourself in a
month!) to read.

A well-chosen, clean list comprehension can, in my opinion, be
considerably easier to read than a corresponding lambda/map/filter, and
can be much more compact than an explicit loop.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Laughter is the only genuine form of applause.
\__/ Camden Benares
    Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html
 A new, virtual planet, every day.




More information about the Python-list mailing list