Python "why" questions

geremy condra debatem1 at gmail.com
Fri Aug 20 14:19:46 EDT 2010


On Fri, Aug 20, 2010 at 11:01 AM, Russ P. <russ.paielli at gmail.com> wrote:
> On Aug 20, 1:23 am, Martin Braun <martin.br... at kit.edu> wrote:
>
>> I find this thread extremely interesting, but what surprised me that
>> everyone seems to agree that mathematics is 1-based, but we Pythoneers
>> should stick to zero-based. I disagree. To make sure I'm not going
>> crazy, I took the top five books lying on my desk, which were the DSP
>> book by Oppenheim/Schafer, two books by Stephen M. Kay (Spectral
>> Estimation and Estimation Theory) and the Channel Coding book by Lin &
>> Costello. This is isn't pure mathematics (as in proving the Goldbach
>> conjecture), but nevertheless, this is serious mathematics and,
>> surprise, they most exclusively use zero-based notation.
>> You probably don't have those books in grabbing distance, so here's some
>> examples for zero-based stuff:
>
> That's interesting, but I think zero-based indexing is rare in the
> literature of mathematics, applied math, science and engineering. All
> the literature I've ever seen that uses vectors and matrices is one-
> based, and that includes text books and technical papers.

Not sure what you read, but for me (mostly number theory, numerical
analysis, and abstract algebra) zero-based indexing is quite common.

> It all boils down to personal preference, but I just find it strange
> that we would not try to make programming as consistent as possible
> with notational conventions in the literature. If I try to implement
> some algorithm I find in a technical book or paper, why should I have
> to mentally offset every index by one? That's very error prone, and I
> have more important things to think about. Then again, I don't do that
> very often, so maybe it's not a big deal.

Ever read code by a mathematician? It's usually (obviously not always)
a nightmare. I'm glad we break with convention, particularly when that
convention is things like one-letter variables and 'reuse' of
notation.

Geremy Condra



More information about the Python-list mailing list