Two-dimensional array tutorial?

M

Martin Schneider

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?

Thanks and best regards,
Martin
 
D

Diez B. Roggisch

Martin said:
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
 
M

Martin Schneider

Diez said:
Can't you just get Numpy (or it's predecessors, Numeric) compiled against
ptyhon2.2?

I tried Numeric, but e.g. it doesn't seem to feature transpose...

How do I compile Numpy against python2.2? :)

Thanks for your answers and best regards,
Martin
 
D

Diez B. Roggisch

Martin said:
I tried Numeric, but e.g. it doesn't seem to feature transpose...

How do I compile Numpy against python2.2? :)


By following the instructions on their website? I don't know Windows, and I
don't know if Numpy is even released for python2.2, as that is ancient. If
not, you're pretty much out of luck.

Diez
 
R

Robert Kern

Martin said:
I tried Numeric, but e.g. it doesn't seem to feature transpose...

Yes, it does. Numeric.transpose()
How do I compile Numpy against python2.2? :)

You cannot. The first version of numpy required Python >= 2.3.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 
M

Martin Schneider

Robert said:
Yes, it does. Numeric.transpose()

Then I must have made a mistake. I'll look into it. Thanks for the
correction.
You cannot. The first version of numpy required Python >= 2.3.

Yeah, I read in your other post, which crossed mine. Sh*t :)

Thanks and best regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top