python for loop

Lada Kugis lada.kugis at
Wed Apr 1 04:58:48 CEST 2009

On Tue, 31 Mar 2009 19:30:15 -0700 (PDT), woooee at wrote:

>Counting from zero through n-1 is used because it is the memory offset
>and not any kind of counter.  Simplified, if you are iterating through
>a list, using a for loop or anything else, the first element/number is
>at memory offset zero because it is at the beginning.  And if this is
>a list of 4 byte integers, the offset for the second element is 1*4
>bytes, etc.  This idea, that somehow the first element of a list is
>the zero element is a fairly recent abnormality AFAIK.  It perhaps
>comes from assumptions by people who are not familiar with what
>happens inside of a programming language, assuming incorrectly, that

I thoughts high level languages were created primarily so we don't
have to think about what happens inside a programming language, memory
offsets and the like.

>the (programming) world was created in their own image, and so
>programming languages were generated in the way that they think they
>were.  This is a bad assumption for any programmer.  Instead one
>should get in the habit of saying, in general as well as in this
>specific case, "This doesn't make sense.  I wonder how __I__ screwed
>this up."  Hopefully this will be helpful advice.  Taking the attitude
>that you have screwed up yet again will get to the heart of the
>problem, and save many hours of frustration wondering why "this
>language/computer doesn't do what it is supposed to do".

Why do we try to create languages that are intuitive to humans, then ?


More information about the Python-list mailing list