Arrays?

John Hunter jdhunter at nitace.bsd.uchicago.edu
Wed Nov 13 14:46:24 EST 2002


>>>>> "e-tones" == e-tones co uk <admin at e-tones.co.uk> writes:

    e-tones> Hi all, right... wanted to create an array in my python
    e-tones> program (2 dimensional), but I dont think it can,
    e-tones> o-rather it can, it just doesnt call it an array (damm
    e-tones> stupid thing :p)

A little more information would help.

Is this a 2D array of numbers, strings, objects?  Are all the elements
of the array of the same type?

For lightweight, general purpose 2D array, use a list of lists

x = [ ['Hi', 1], ['Bye', 2] ]
print x[1][1]

For heaviweight, fast 2D numeric arrays, use Numeric (aka numpy)

http://www.pfdubois.com/numpy/

You may find this thread on google.groups helpful:

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&frame=right&th=6e8e008dcc5f3dbf&seekm=791h4a%24fp%241%40rzsun02.rrz.uni-hamburg.de#link1


Cheers,
John Hunter




More information about the Python-list mailing list