python 3d array like in C ++
Question: I'd like to make a 3 dimensional array like this one :

    
    
    treedarray = [[[0, 0, 0], [0, 0, 0], [0, 0, 0]],
    [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
    [[0, 0, 0], [0, 0, 0], [0, 0, 0]]]
    

in this table, every value is (easily) accessible by using :

    
    
    treedarray [a] [b] [c]
    

I'd like to know if there is a command to do that more easily.

Thanks in advance.


Answer: Using [Numpy](http://www.numpy.org/) and
[numpy.zeros()](http://docs.scipy.org/doc/numpy/reference/generated/numpy.zeros.html)
you can define the shape with a list of values as the first param. e.g.

    
    
    import numpy as np
    
    treedarray = np.zeros([3,3,3])
    print treedarray
    

Outputs:

    
    
    [[[ 0.  0.  0.]
      [ 0.  0.  0.]
      [ 0.  0.  0.]]
    
     [[ 0.  0.  0.]
      [ 0.  0.  0.]
      [ 0.  0.  0.]]
    
     [[ 0.  0.  0.]
      [ 0.  0.  0.]
      [ 0.  0.  0.]]]
    

And can access the pretended value using, `treedarray[a][b][c]`.

