referencing disjoint array indexes

Gerhard Häring gerhard.haering at opus-gmbh.net
Mon Nov 11 07:48:35 EST 2002


In article <DnNz9.11696$cP3.22276 at news.iol.ie>, Padraig Brady wrote:
> Hi,
> 
> Is there any way you can do something like
> 
> size, mtime = os.stat()[8,6]

If there isn't any better way, you can easily implement a little helper function yourself:

>>> def seqfromidxs(seq, *idxs):
...   lst = []
...   for idx in idxs:
...     lst.append(seq[idx])
...   return lst
...
>>> # now let's try it out:
>>> aseq = "abcdefg"
>>> c1, c2 = seqfromidxs(aseq, 3, 5)
>>> c1, c2
('d', 'f')

-- 
Gerhard Häring
OPUS GmbH München
Tel.: +49 89 - 889 49 7 - 32
http://www.opus-gmbh.net/



More information about the Python-list mailing list