negative indices for sequence types
mpeuser at web.de
Mon Sep 8 08:01:16 CEST 2003
"dan" <danbmil99 at yahoo.com>
> I was recently surprised, and quite shocked in fact, to find that
> Python treats negative indices into sequence types as if they were
> mod(length-of-sequence), at least up to -len(seq).
> This fact is *deeply* buried in the docs, and is not at all intuitive.
I think it is addressed even in most tutorials because it is quite handy as
others already pointed out. There is the same fetaure in Perl.
More information about the Python-list