Two-dimensional array tutorial?
Diez B. Roggisch
deets at nospam.web.de
Wed Oct 22 10:05:07 EDT 2008
Martin Schneider wrote:
> Hi!
>
> I'd like to handle two-dimensional arrays. My first choice, the numpy
> library, doesn't seem to be an option due to compatibility issues (see
> my other thread about python22.dll).
>
> Is there a tutorial somewhere how to handle 2d-arrays with vanilla Python?
there isn't much to them, simply create an use:
foo = [[0 for _ in xrange(height)] for _ in xrange(width)]
or something similar. Then you just use
foo[x][y]
to access individual elements.
Alternatively, you can use the module "array" for the inner list to be more
memory-efficient.
Obviously you don't get any further operations on arrays such as
transposition, multiplication and the like.
Can't you just get Numpy (or it's predecessors, Numeric) compiled against
ptyhon2.2?
Diez
More information about the Python-list
mailing list