Another Wart! string.find() [ was: namespace issue? ]

Chuck Esterbrook ChuckEsterbrook at
Fri Jun 22 04:46:39 CEST 2001

At 10:19 PM 6/21/2001 -0400, Steven D. Majewski wrote:
>On 21 Jun 2001, Chuck Esterbrook wrote:
> > "Steven D. Majewski" <sdm7g at Virginia.EDU> wrote in message 
> news:<mailman.993163773.29922.python-list at>...
> > [snip]
> > >
> > >   I'ld love to see it fixed, however, I suspect that in this case,
> > >   many lines of installed code trumps Computer Programming for 
> Everybody!
> > >
> >
> > So is it a flaw, relative to CP4E, that sequences start at index 0
> > instead of 1? An 'everybody' kind of person would think of the "first"
> > element as e[1]. Only someone familiar with pointer arithmetic from C
> > or assembly would think that "first" is 0.
>No -- that's not a "flaw" , it's an "engineering tradeoff" -- i.e.
>you can't please everyone all the time!
>Zero is natural whenever you are thinking in terms of offsets:
>   every ruler starts with an implied 0 inches (or cm. or other).

Rulers don't have much to do with lists. The first measures; the second 

Also, if you ask an 'ordinary' person to write down a list of numbered 
items on paper, they will give you:

1. red
2. green
3. blue

>Zero based indexing makes slice indexing much easier to figure --
>   one-based indexing would make that more confusing to everyone.

Perhaps. There are different ways to do slices. Python uses a start and a 
stop. Obj-C uses a start and a count. They both have their neat little 
properties, but in the end they seem about even.

>Lots of other technical fields besides programming use zero based
>  indexing -- where do you think C got it ? Probably from mathematics

I know exactly where C got it from: assembly.

In assembly if you have a label FOO that points to your array, then to get 
the first element of that array you add 0, for the second add 1 (times the 
size of the element), for the third add 2, etc. C kept that approach.

It had nothing to do algebra, trig, etc.

>  or engineering. Most high-school grads should be familiar with
>  the notation.

AFAIK the standard mathematical notation for tuples is (x1, x2, ..., xN). A 
high school grad who remembers that will expect 1, not 0.

You can find a reference at:

>Yeah -- there are arguments for 1 over 0, but whatever you choose
>is going to be 'wrong' for somebody, some of the time.

The context I created was CP4E. Consequently, I think 1 is a much stronger 
case than 0. This is similar to the 3/5 = 0.6 vs. 0 debate. Under a CP4E 
ideology, 0.6 wins.

>And not surprising C programmers does have *some* value.

I suppose.  :-)


More information about the Python-list mailing list