Python "why" questions

Russ P. russ.paielli at gmail.com
Thu Aug 19 06:55:30 CEST 2010


On Aug 18, 7:58 pm, Steven D'Aprano <steve-REMOVE-
T... at cybersource.com.au> wrote:
> On Wed, 18 Aug 2010 14:47:08 -0700, Russ P. wrote:
> > Is the top team in the league the number 1 team -- or the number 0 team?
> > I have yet to hear anyone call the best team the number 0 team!
>
> Why is the top team the one with the lowest number?

How could it be otherwise? What is the highest number?

Here's a couple of things I'd like to see just once before I die:

1. The winner of the championship game chanting, "We're number zero!
We're number zero!

2. The loser of the championship game chanting, "We're number one!
We're number one!

>
> > Unfortunately, we're stuck with this goofy numbering system in many
> > languages. Fortunately, the trend is away from explicit indexing and
> > toward "for" loops when possible.
>
> Agreed on the second sentence there, but not on the first. There's
> nothing "goofy" about indexing items from 0. Yes, it does lead to slight
> more difficulty when discussing which item you want in *human* languages,
> but not in *programming* languages. The nth item is always the nth item.
> The only difference is whether n starts at 0 or 1, and frankly, if you
> (generic you, not you personally) can't learn which to use, you have no
> business pretending to be a programmer.

Maybe "goofy" was too derogatory, but I think you are rationalizing a
bad decision, at least for high-level languages. I don't think
programming languages should always mimic human languages, but this is
one case where there is no advantage to doing otherwise.

Why do you think "off by one" errors are so common? Because the darn
indexing convention is off by one!

And I'd still like to know if the "1st" element of aList is aList[0]
or aList[1].



More information about the Python-list mailing list