On 1/26/2011 12:52 PM, Benjamin Kaplan wrote:

If you're trying to learn a language, I would suggest reading
tutorials, not the grammar.

I second that.

As you can see from the error thrown, the
operation is syntactically valid (you don't get a syntax error). It's
just that lists don't accept them. I don't know of any built-in data
type that takes slice lists but numpy matrices will.

a = numpy.matrix([[1,2,3],[4,5,6],[7,8,9]])
matrix([[1, 2, 3],
         [4, 5, 6],
         [7, 8, 9]])

a[0:2,1:3]
matrix([[2, 3],
         [5, 6]])

Which is to say, slice lists are a specialized feature added specifically for numerical python, now numpy. Ignore then unless and until you happen to install and use numpy, or something similar that also uses them.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to