multi-dimensional array ??
Peter Schneider-Kamp
nowonder at pool.informatik.rwth-aachen.de
Mon Jul 24 12:01:12 EDT 2000
Thomas Weholt wrote:
>
> I need to hold x,y,z coordinates in a multi-level grid. How can this
> be done in Python?
You can use lists of lists of lists of 3-tuples containing the
coordinates. Adressing is done via repeated indexing.
For example the corners of a unit cube between 0 and 1:
>>> a = [ [ [(0,0,0), (0,0,1)], [(0,1,0), (0,1,1)] ],
... [ [(1,0,0), (1,0,1)], [(1,1,0), (1,1,1)] ] ]
>>> a[0][0][0]
(0, 0, 0)
>>> a[1][0][1]
(1, 0, 1)
>>>
You can also use NumPy. Chances are (if only slight ones)
that it will be included with 2.0 (see PEP 206
http://python.sourceforge.net/peps/pep-0206.html)
Peter
--
Peter Schneider-Kamp ++47-7388-7331
Herman Krags veg 51-11 mailto:peter at schneider-kamp.de
N-7050 Trondheim http://schneider-kamp.de
More information about the Python-list
mailing list