Fetching multiple items from a list

Joonas Paalasmaa joonas.paalasmaa at nokia.com
Tue Jul 3 08:18:39 EDT 2001


Why doesn't Python support fetching and setting multiple items
at the same time for lists and tuples.

For example in the example below multiple fetching would be
much better way than the ordinary way.

>>> import string
>>> mylist = list(string.lowercase)
>>> mylist[18],mylist[15],mylist[0],mylist[12]
('s', 'p', 'a', 'm')
>>> mylist[18,15,0,12]
Traceback (most recent call last):
  File "<pyshell#23>", line 1, in ?
    mylist[18,15,0,12]
TypeError: sequence index must be integer
>>>



More information about the Python-list mailing list