List of lists of lists of lists...

Robert Kern robert.kern at
Wed May 10 03:26:47 CEST 2006

James Stroud wrote:

> Numarray does this sort of thing, but you have to familiarize yourself 
> with its indexing conventions:
> py> import numarray
> py> numarray.ones((3,2))
> array([[1, 1],
>         [1, 1],
>         [1, 1]])
> py> numarray.ones((1,2,3))
> array([[[1, 1, 1],
>          [1, 1, 1]]])

numpy is the successor to numarray, so if you are just starting with arrays,
please get started with numpy. It should also be noted that numpy can create
arrays of objects as well as arrays of numbers.

In [1]: from numpy import *

In [2]: empty((1,2,3), dtype=object)
array([[[None, None, None],
        [None, None, None]]], dtype=object)

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

More information about the Python-list mailing list