python for loop

Mensanator mensanator at aol.com
Wed Apr 1 13:47:27 EDT 2009


On Apr 1, 9: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:
>
> >Lada,
>
> >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 ?

Here's an easy example: Standard Positional Number Systems.

765 in octal is

7 * 8**2 +
6 * 8**1 +
5 * 8**0

123 in decimal is

1 * 10**2 +
2 * 10**1 +
3 * 10**0

666 in hexadecimal is

6 * 16**2 +
6 * 16**1 +
6 * 16**0

0-based indexing is kinda important.

> (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)
>
> Lada- Hide quoted text -
>
> - Show quoted text -




More information about the Python-list mailing list