python for loop
pavlovevidence at gmail.com
Wed Apr 1 19:05:36 CEST 2009
On Apr 1, 7:08 am, Lada Kugis <lada.ku... at gmail.com> wrote:
> On Wed, 1 Apr 2009 00:40:17 -0700 (PDT), Carl Banks
> <pavlovevide... at gmail.com> wrote:
> >I am also an engineer, and I can tell your idea of intuitive is not
> >universal, even among engineers. I certainly do not lean toward one-
> >based indexing.
> >From a programming standpoint--and remember Python is a programming
> >language--zero-based indexing eliminates the need for a whole lot of
> >extra +1s and -1s when indexing, slicing, and iterating, a lot more
> >than it causes, and that is worth the "cost". This might not be
> >apparent to you if you never tried seriously taking advantage of
> >indexing from zero, or if your programming experience is very narrow.
> >These both seem to be true for you, so you'll just have to take my
> >word for it.
> You have repeated several cs based points already stated. But apart
> from a programming standpoint - could you give a few examples, where
> "on paper" (as to avoid stepping into "programmer's territory") zero
> indexing could be more intuitive ?
That's beside the point. Python's job is to be usable as a
programming language. It made a decision to use zero-based indexing
so as to simplify programming usage. Therefore, that's what you have
to use for matrix indices, whether it is intuitive for you or not.
I have no real opinion whether zero- or one-based indexing works best
on paper for engineering calculations, except that it's a trivial
> (of course, taking into account your previous based calculations,
> which are based on 1 indexing - I imagine you still use matrices with
> a11 as a first element)
I don't know what you're referring to by my previous based
calculations, and the sentences doesn't make sense, so I can't answer
FTR: I use zero-based matrix indices when I'm using a language with
zero-based indexing, and one-based indices when using a language with
one-based indexing. Simple as that. You should do the same.
More information about the Python-list