Creating multi-dimensional arrays
Kirill Simonov
kirill at xyz.donetsk.ua
Thu Aug 9 23:18:30 EDT 2001
On Wed, Aug 08, 2001 at 08:55:21AM +0000, spam_buster_2000 at yahoo.com wrote:
> I've been writing a couple of programs recently which use multi-dimensional arrays of
> a predefined size, and I was wondering if there was a standard idiomatic way of creating
> these in Python. I'm not looking to restrict the arrays to contain specific types, so just
> pointing me to Numeric isn't the answer here.
You can use dictionaries instead of nested lists:
a = {}
for i in range(10):
for j in range(10):
for k in range(10):
a[i,j,k] = 0
More information about the Python-list
mailing list