[Python-Dev] List comprehensions

Paul Prescod paul@prescod.net
Thu, 13 Jul 2000 12:27:07 -0500


"M.-A. Lemburg" wrote:
> 
> ...
>
> Is it really necessary to have all the "code" inside the square
> brackets ?

That's what a list comprehension is! Check the defacto PEP:

http://www.cosc.canterbury.ac.nz/~greg/python/listcomp/

I take it you are against list comprehensions.
 
> I always thought of list comprehension as a fast way to
> just throw together a list, not as a way to "program" the
> list contents. IMHO, that should be done using explicit
> statements in the way Skip describes above.
> 
> I would be completely satisfied with e.g. [0..10], [0..10:2]
> and [10..0].

Those are not list comprehensions but "range literals." Actually, the
syntax we are using is [0:10], [0:10:2], [10:0]. I prefer dotdot, but
Guido chose the colon a decade ago.

-- 
 Paul Prescod - Not encumbered by corporate consensus
Simplicity does not precede complexity, but follows it. 
	- http://www.cs.yale.edu/~perlis-alan/quotes.html