Slicing / subsetting list in arbitrary fashion
Fredrik Lundh
fredrik at pythonware.com
Fri Nov 17 12:39:29 EST 2006
Gregg Lind wrote:
> One difficulty I am having with using Python for scientific computing is
> that I cannot figure out good ways to get arbitrary (unpatterned?) slices.
> In Python, solutions I have found for these tasks are:
>
> [vals[ii] for ii in wanted] # task 1
>
> [a[1] for in zip(Truths,vals) if a[0] ] # task 2
array objects have "take" and "put" methods; see e.g. (random google link):
http://stsdas.stsci.edu/numarray/Doc/node33.html
</F>
More information about the Python-list
mailing list