Lower bounds of lists
Bruce Sass
bsass at freenet.edmonton.ab.ca
Fri Mar 2 01:49:48 EST 2001
> > It seems an odd choice, as humans count from one, and Python in
> > other respects seems quite logical and well thought out.
>
> Humans count from 1. Hackers count from 0.
Not really - it's an index (the offset from the start), not a count.
If you are at the start of something, the offset is 0.
<...>
> C does it that way. So, in general, does assembler, and the internal
> representation of unsigned integer numbers runs from 0 to (2^bits)-1,
> where bits is the number of bits of data storable.
>
> Counting from 0 is counter-intuitive to humans, but so is much of
> computer science. Ultimately, it's because Guido wanted it that way.
Consider this... maybe you are not really counting, you are actually
building a list then referring to the items in it.
Once you get your head in the right space it all becomes clear.
HTH
- Bruce
More information about the Python-list
mailing list