Hello Python Tutor!

I have been using Python for years now, in all kinds of environments, but
I don't really understand the restrictions on slicing.

As described in http://jtauber.com/blog/2005/08/16/python_slice_questions/
and
http://mail.python.org/pipermail/python-list/2006-February/368291.html,
in matrix oriented languages like R, Octave / Matlab, and NumPy, vectors,
lists, and matrices support slice lists of arbitrary indices.

example:  x is vector of length 5, with value "a","b","c","d","e" , then:

x[3,1,1,1,3,2] # gives [d, b, b, b, d, c]


What is the python equivalent?
  a.  Am I understanding the situation correctly?
  b.  Why was this particular way of doing slices chosen?
  c.  What is the best solution for "masking" vectors?  Is it to use
filter?    Using NumPy?  To use a list comprehension, a la:

[a[j] for j in good_indices]



(I ask this because I think this is a misfeature, and I hope that I can be
corrected in my perception, not because I dislike Python.  Quite the
contrary!)

Thanks,

Gregg Lind


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to