[Python-Dev] PEP 204 - Range Literals
Wed, 19 Jul 2000 09:58:56 -0700 (PDT)
On Tue, 18 Jul 2000, Paul Prescod wrote:
> Should range literals create a list of the passed-in type ? It
> might be desirable in the cases of other builtin types, such as
> longs and strings:
> >>> [ 1L : 2L<<64 : 2<<32L ]
> >>> ["a":"z":"b"]
> >>> ["a":"z":2]
> However, this might be too much `magic' to be obvious.
Too much magic. Remember the analogy is with the slice
operator: lst[start:end]. Only integers work there, and
only integers are acceptable to range() now, so it's simpler
and happier all around to keep the range literals to just
> Well the step argument is of debatable utility for strings but ["0":"9"]
> seems mildly useful. Also, it makes sense to create a range of floating
> point numbers.
Not useful enough, i think, to be worth it. If you need to
do a range check, you can still say "a" <= x <= "z".
When working with ranges or regions on the number line,
you probably want something more specifically designed for
that. (For example, you might want to talk about open,
closed, or half-open intervals.) If we're going to
consider the feature, E's CoordinateSpaces and Regions
are worth a serious look.
Hmm. I don't have a good reference on that. I'll post
one when i find it.