[Python-Dev] Lukewarm about range literals

Peter Schneider-Kamp nowonder@nowonder.de
Tue, 29 Aug 2000 00:41:57 +0000


Greg Wilson wrote:
> 
> I would vote -1 on [0...100:10] --- even range(0, 100, 10) reads better,

I don't like [0...100] either. It just looks bad.
But I really *do* like [0..100] (maybe that's Pascal being my first
serious language).

That said, I prefer almost any form of range literals over the current
situation. range(0,100) has no meaning to me (maybe because English is
not my mother tongue), but [0..100] looks like "from 0 to 100"
(although one might expect len([1..100]) == 100).

> but in my experience, students coming to Python from other languages seem
> to expect to be able to say "do this N times" very simply.  Even:
> 
>     for i in range(100):
> 
> raises eyebrows.  I know it's all syntactic sugar, but it comes up in the
> first hour of every course I've taught...

I fully agree on that one, although I think range(N) to
iterate N times isn't as bad as range(len(SEQUENCE)) to
iterate over the indices of a sequence.

not-voting---but-you-might-be-able-to-guess-ly y'rs
Peter
-- 
Peter Schneider-Kamp          ++47-7388-7331
Herman Krags veg 51-11        mailto:peter@schneider-kamp.de
N-7050 Trondheim              http://schneider-kamp.de