[Python-Dev] listcomp / par-for (summary)

Paul Prescod paul@prescod.net
Wed, 12 Jul 2000 10:40:11 -0500

Here's my other 1p.

> The range-literal thing ([:10:2] -> [0,2,4,6,8]) seems to be acceptable, I
> believe ? It might 'merely' be syntactic sugar for a builtin, but it's
> such pretty sugar ! :-) 

Let me play devil's advocate to make sure this is fleshed out enough.

How's this for obfuscation:


And arguing from analogy, shouldn't

range(0:bignum)[0:10:2] be [0:10:2]

> And it's not possible to shadow the builtin like with range.

You probably shouldn't be able to shadow most builtins period. 

> (Though I have one possible addition to the range syntax: range tuples, like
> so:
> (20:10:3)

I presume you meant (10:20:3). Right?

> They could just generate a rangeobject, like xrange does... That could be a
> fair bit of memory savings ;) But I have to admit the syntax isn't as
> obvious as [19:15:-1])

I don't follow you here. Anyhow, I like the idea that there should be a
syntax that does the rangeobject thing and it makes sense that it needs
to be immutable.

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