vector subscripts in Python?

Alexander Schmolck a.schmolck at gmx.net
Thu Jun 12 15:53:57 EDT 2003


Alex Martelli <aleax at aleax.it> writes:

> Alexander Schmolck wrote:
>    ...
> > function is worthwhile (note that it allows works for dicts and other
> > iterables).
> > 
> > def at(iterable, indices):
> >     return [iterable[i] for i in indices]
> 
> Careful: it does NOT allow for iterables -- it needs 'indexables', i.e.,
> sequences or mappings. 

Indeed, thanks for that correction. Being iterable is of course only
sufficient for the indices.

'as




More information about the Python-list mailing list