array slices in python

beliavsky at aol.com beliavsky at aol.com
Tue May 13 12:43:57 EDT 2003


> Fortran does things differently, sure, but computer science has moved
> on.  Fortran doesn't index arrays from zero, which there are lots of
> good computer science reasons to do (i.e., offsets into arrays); the
> only pressing reason for indexing from one is because that's the way
> some mathematical formulae are written, but that's not a very convincing
> argument since it's a trivial substitution to change a [1, n] range to a
> [0, n) one.

By default, Fortran indexes arrays from zero, but you can have arrays
with other offsets. After the Fortran 95 declaration

real :: x(3),y(-1:2)

x has 3 elements and y has 5, starting with y(-1).




More information about the Python-list mailing list