assigning a sequence to an array

amitsoni.1984 at gmail.com amitsoni.1984 at gmail.com
Wed Nov 8 07:35:13 EST 2006


actually what i want to do is this:
i have a file with following format:
1 2
3 9
2 3
4 4

I want to read it and then store the values into two matrices, s.t.
A=[1 2;3 9]
B=[2 3;4 4]

any easier way of doing this?
thanks
Amit

Robert Kern wrote:
> amitsoni.1984 at gmail.com wrote:
> > Hi,
> > I am using  "A[a,:]=row" in python, where A is a matrix and row is a
> > sequence. But it gives following error:
> > -------- error------
> >     A[a,:]=row
> > ValueError: setting an array element with a sequence.
> >
> > Is there a way to change type of sequence to array so that this
> > situation could be handled
>
> You don't say what array package you are using. I presume numpy. In any case,
> the place to ask those questions (even for the older numarray and Numeric
> packages) is the numpy list.
>
>   http://www.scipy.org/Mailing_Lists
>
> We will need some more information from you when you come to the numpy list.
> Please reduce your problematic code to the smallest, self-contained script that
> demonstrates the problem, and post it and the exact output that you get.
>
> --
> 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




More information about the Python-list mailing list