Name for Python's list index system

Terry Reedy reedy37 at home.com
Fri May 25 11:26:25 EDT 2001


> > A much-appreciated feature of Python is its subscripting/indexing
system
> > which allows you to write
> >
> >     list[-1]    # Get last element
> >     list[-2]    # Get 2nd to last element
> >
> > ...etc.
> >
> > Do this feature have any "official" name in Python? If not, then I
think
> it
> > should. Perhaps "modulo" or "modular" indices? (Could be abbreviated to
> > "mod")

> It's called slicing.

No!  Reverse indexing, like normal forward indexing, returns exactly one
item or raises an exception.  Slicing requires two positions (either
possibly implied) and returns 0 to all items.

Terry J. Reedy






More information about the Python-list mailing list