Webb Sprague wrote: > it is far more natural to program if the indices are aligned with the > counts of the elements
I suggest that it's only more natural if that's what you're used to -- i.e. you come form other languages that do it that way. I fairly rarely get bitten by indexing 1, rather than zero, but I save a lot of errors that I used to get in MATLAB by the way python does slices: len(a[i:j]) == j - i and: l[:j] + l[j:] == l or: r_[a[:i],a[i:]] == a for numpy arrays. I suppose you could have one-indexing and the python slicing, but I think that would be even more error prone. > zero > based indexing made lots of sense since it dovetailed with thinking in > memory offsets in systems programming it also dovetails nicely into using an array to represent a grid of values: i = (X - MinX) / deltaX rather than i = (X - MinX) / deltaX + 1 X = i*deltaX rather than X = (i-1)*deltaX In Fortran, you can choose where you want your array indexing to start, and I found myself starting with zero more often than 1, and I was never a C programmer. > I guess I just want to vent, but also to ask if anyone > has found any way to deal with this issue in their own scientific > programming. You'll get used to it. There are disadvantages either way, but after switching from primarily Matlab to primarily Python, I like zero-based indexing better. Perhaps you will too. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion