Python "why" questions
greg.ewing at canterbury.ac.nz
Mon Aug 16 02:33:51 CEST 2010
Ian Kelly wrote:
> On Fri, Aug 13, 2010 at 11:53 AM, Martin Gregorie
> <martin at address-in-sig.invalid> wrote:
>> real sample[-500:750];
> Ugh, no. The ability to change the minimum index is evil.
Not always; it can have its uses, particularly when you're
using the array as a mapping rather than a collection.
Pascal had a nice feature where you could use any ordinal
type as an array index, and sometimes it was handy to
have things like an array indexed by the characters
'A' to 'Z', or the values (Red, Green, Blue). Typically
you didn't need to do arithmetic on the indices in those
Python addresses this by having separate types for
sequences and mappings.
More information about the Python-list