Python "why" questions
Ben Finney
ben+python at benfinney.id.au
Sat Aug 7 19:34:22 EDT 2010
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> It didn't take me long to get used to thinking in zero-based indexes,
> but years later, I still find it hard to *talk* in zero-based indexes.
> It's bad enough saying that the first element in a list in the zeroth
> element, but that the second element is the first makes my head
> explode...
Don't say those things, then. In addition to making your head explode,
they're not true.
There is no “zeroth element” in a sequence.
The first element in a sequence is addressed by index 0.
The second element in a sequence is addressed by index 1.
The last element in a sequence is addressed by index -1.
In other words, it's never true (in Python) that index N addresses the
Nth element of the sequence; so that's not a useful equivalence to
maintain.
Hope that helps.
--
\ “The trouble with eating Italian food is that five or six days |
`\ later you're hungry again.” —George Miller |
_o__) |
Ben Finney
More information about the Python-list
mailing list