Perl's @foo[3,7,1,-1] ?

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Tue Jun 16 22:14:34 EDT 2009


On Wed, 17 Jun 2009 01:50:55 +0000, Alan G Isaac wrote:

> On 6/13/2009 2:11 PM kj apparently wrote:
>> Switching from Perl here, and having a hard time letting go...
>> 
>> Suppose I have an "array" foo, and that I'm interested in the 4th, 8th,
>> second, and last element in that array.  In Perl I could write:
>> 
>>   my @wanted = @foo[3, 7, 1, -1];
> 
>>>> a = np.arange(10)
>>>> a
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>>> a[[3,7,1,-1]]
> array([3, 7, 1, 9])
> 
> hth,
> Alan Isaac


What's np.arange?




-- 
Steven




More information about the Python-list mailing list