My first stumbling block with Python

Mr. Neutron nicktsocanos at
Thu Aug 22 15:12:52 CEST 2002

Sigh, it was too good to be true. I have come across my first problem
with Python programming.

Python does not seem to have an Array type. It has the Array object,
which is a one dimensional array, and it works fine. However, I need a
two dimensional array mapped (X,Y) of tuples.

I can think of ways to do this in the language, by creating a list of all
the elements, and creating a function def GetPos(X,Y) that maps into the
list and gets the element. The math isn't too hard off the top of my head
it is like
		return list[ (Y * RowSize) + X ]

	and SetPos(X,Y, MyTuple)
		list[ (Y*RowSize) + X ] = MyTuple

Where RowSize is the width of the array.

Now the question is, are there any easier or better ways to get a two
dimensional array of tuples in Python

Something like 

		MyArray[X][Y] = (tuple)

More information about the Python-list mailing list