[PYTHON MATRIX-SIG] Nested list representation of an array

David Ascher da@maigret.cog.brown.edu
Mon, 28 Oct 1996 13:15:41 -0500 (EST)


> > Does anyone know an efficient way to obtain a nested list
> > representation of an array? list() will handle only the first
> > axis. The best I can come up with is a recursive definition:
> 
> Not sure this is in the docs yet, but a.tolist() will do what you want
> quite efficiently.

Yup:

`a.tolist()'
------------

Calling an array's `tolist()' method returns a hierarchical python list
version of the same array:
     >>> a
     0 1 2
     3 4 5
     6 7 8
     >>> a.tolist()
     [[0, 1, 2], [3, 4, 5], [6, 7, 8]]



=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================