[Python-Dev] Lukewarm about range literals (original) (raw)

Greg Wilson gvwilson@nevex.com
Tue, 29 Aug 2000 07:28:58 -0400 (EDT)


> Ka-Ping Yee <ping@lfw.org>: > for i in 1 .. 10: > print i*i > for i in 0 ..! len(a): > a[i] += 1

Greg Wilson writes:

The problem with using ellipsis is that there's no obvious way to include a stride --- how do you hit every second (or n'th) element, rather than every element? I'd rather stick to range() than adopt:

for i in [1..10:5]

Thanks, Greg

BTW, I understand from side conversations that adding a 'keys()' method to sequences, so that arbitrary collections could be iterated over using:

for i in S.keys():
    print i, S[i]

was considered and rejected. If anyone knows why, I'd be grateful for a recap.