referencing disjoint array indexes

Padraig Brady Padraig at Linux.ie
Mon Nov 11 07:59:55 EST 2002


Gerhard Häring wrote:
> 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
> ...

Well you should probably return a tuple rather than a list?
But problems with this is that you do it manually (slow/messy).
Also it doesn't support slicing.

In general it would by nice (IMHO) to support:

size, times = os.stat("/bin/vi")[6,7:]

Maybe it's crud, but I've found myself wishing the
functionality was there a few times (not just for os.stat).

thanks,
Pádraig.




More information about the Python-list mailing list