Multi-dimension list

Carl Banks pavlovevidence at
Wed Dec 24 06:36:16 CET 2008

On Dec 23, 10:29 pm, "Steven Woody" <narkewo... at> wrote:
> Hi,
> In the book Python Essential Reference, Chapter 3, when talking about
> extended slicing, it gives an example:  a = m[0:10, 3:20].  But I
> don't understand how the 'm' was defined.  What should it looks like?

I suspect what the book is saying is that the Python language will
accept and multidimensional indexing and slicing (it's legal syntax),
even though there are no types built into Python that use
multidimensional slicing.

However, some third party libraries do provide types that allow
multidimensional indexing and slicing, most notably numpy.

So, for instance, if you were install numpy, you could get
multidimensional arrays and slice 'em up however you'd like:

import numpy
a = numpy.array([[1,2,3],[4,5,6],[7,8,9]])
print a[1:3,0:2]

Carl Banks

More information about the Python-list mailing list