Newsgroups: comp.lang.python
From: "Alex Martelli" <alea...@yahoo.com>
Date: Sat, 12 May 2001 01:15:24 +0200
Local: Fri, May 11 2001 7:15 pm
Subject: Re: inclusive-lower-bound, exclusive-upper-bound (was Re: Range Operation pre-PEP)
news:3AFBA6E0.6ABBCD93@one.net.au...
... > OK, next question: why does Python start indexes at zero? Your example If indexes started at 1, then maybe so should ranges. However, > would work perfectly well if the range returned [1, 2, 3, 4] and the > list was indexed starting with 1. Basically, range(4) has to produce a > list of four items, we just differ on what those items should be. having read the followups to this message, I think there are still advantages of simplicity and regularity in having arrays (even if one calls them lists:-) indexed from 0. My master thesis, lo that many years ago, included a large program in Fortran IV (1-based index only) and had to do a lot of +1/-1 twiddling because of that. I didn't understand why at the time (having not yet met Koenig's book "C traps & pitfalls", which introduced me to the many advantages of half-open ranges -- array indexing being a case of that), but now I think I do. Suppose my 1-dimensional array/list needs at some point to If everything starts from 0: And the reverse, too -- given M and N, OK, what about the "main diagonal" of the intrinsic 2D OK, forget subarrays. Say we just have two very long OK, so, what's the I-th element of our result? You will no doubt find some counterexamples too, but Alex You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||