vector subscripts in Python?
beliavsky at aol.com
beliavsky at aol.com
Wed Jun 11 19:12:38 EDT 2003
Does Python have the equivalent of "vector subscripts" of Fortran 95?
The code below illustrates what I am looking for -- with better syntax.
def subscript(xx,ii):
# return the elements in xx subscripted by ii
y = []
for i in ii: y.append(xx[i])
return y
ii = [0,2]
xx = [1,4,9]
print subscript(xx,ii) # returns [1, 9]; in F95, "print*,xx(ii)" is analogous
More information about the Python-list
mailing list