Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

Two-dimensional array tutorial?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


martin.schneider at illusion-factory

Oct 22, 2008, 6:46 AM

Post #1 of 6 (770 views)
Permalink
Two-dimensional array tutorial?

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
--
http://mail.python.org/mailman/listinfo/python-list


deets at nospam

Oct 22, 2008, 7:05 AM

Post #2 of 6 (747 views)
Permalink
Re: Two-dimensional array tutorial? [In reply to]

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
--
http://mail.python.org/mailman/listinfo/python-list


martin.schneider at illusion-factory

Oct 22, 2008, 7:18 AM

Post #3 of 6 (753 views)
Permalink
Re: Two-dimensional array tutorial? [In reply to]

Diez B. Roggisch schrieb:
> 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
--
http://mail.python.org/mailman/listinfo/python-list


deets at nospam

Oct 22, 2008, 7:24 AM

Post #4 of 6 (748 views)
Permalink
Re: Two-dimensional array tutorial? [In reply to]

Martin Schneider wrote:

> Diez B. Roggisch schrieb:
>> 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? :-)


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
--
http://mail.python.org/mailman/listinfo/python-list


robert.kern at gmail

Oct 22, 2008, 7:35 AM

Post #5 of 6 (756 views)
Permalink
Re: Two-dimensional array tutorial? [In reply to]

Martin Schneider wrote:
> Diez B. Roggisch schrieb:
>> 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...

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

--
http://mail.python.org/mailman/listinfo/python-list


martin.schneider at illusion-factory

Oct 22, 2008, 7:40 AM

Post #6 of 6 (751 views)
Permalink
Re: Two-dimensional array tutorial? [In reply to]

Robert Kern schrieb:
> Martin Schneider wrote:
>> I tried Numeric, but e.g. it doesn't seem to feature transpose...
>
> Yes, it does. Numeric.transpose()

Then I must have made a mistake. I'll look into it. Thanks for the
correction.

>> How do I compile Numpy against python2.2? :-)
>
> 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
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.