I have the following Python list (can also be a tuple):
myList = [\'foo\', \'bar\', \'baz\', \'quux\']
I can say
>>&g
It isn't built-in, but you can make a subclass of list that takes tuples as "indexes" if you'd like:
class MyList(list):
def __getitem__(self, index):
if isinstance(index, tuple):
return [self[i] for i in index]
return super(MyList, self).__getitem__(index)
seq = MyList("foo bar baaz quux mumble".split())
print seq[0]
print seq[2,4]
print seq[1::2]
printing
foo
['baaz', 'mumble']
['bar', 'quux']