Re: Multidimensional arrays/lists

2009-09-28 Thread Simon Forman
On Mon, Sep 28, 2009 at 3:27 PM, Ethan Furman wrote: > Simon Forman wrote: >> >> On Sun, Sep 27, 2009 at 12:40 PM, Someone Something >> wrote: >> >>> I'm trying to write a little tic-tac-toe program I need a array/list such >>> that I can represent the tic tac toe board with an x axis and y axis

Re: Multidimensional arrays/lists

2009-09-28 Thread Ethan Furman
Simon Forman wrote: On Sun, Sep 27, 2009 at 12:40 PM, Someone Something wrote: I'm trying to write a little tic-tac-toe program I need a array/list such that I can represent the tic tac toe board with an x axis and y axis and i can access each square to find out whether there is an X or an O.

Re: Multidimensional arrays/lists

2009-09-27 Thread Simon Forman
On Sun, Sep 27, 2009 at 12:40 PM, Someone Something wrote: > I'm trying to write a little tic-tac-toe program I need a array/list such > that I can represent the tic tac toe board with an x axis and y axis and i > can access each square to find out whether there is an X or an O. I have > absolutel

Re: Multidimensional arrays/lists

2009-09-27 Thread Rhodri James
On Sun, 27 Sep 2009 17:40:57 +0100, Someone Something wrote: I'm trying to write a little tic-tac-toe program I need a array/list such that I can represent the tic tac toe board with an x axis and y axis and i can access each square to find out whether there is an X or an O. I have absolut

Re: Multidimensional arrays/lists

2009-09-27 Thread Gary Herron
Someone Something wrote: I'm trying to write a little tic-tac-toe program I need a array/list such that I can represent the tic tac toe board with an x axis and y axis and i can access each square to find out whether there is an X or an O. I have absolutely no idea how to do this in python and

Multidimensional arrays/lists

2009-09-27 Thread Someone Something
I'm trying to write a little tic-tac-toe program I need a array/list such that I can represent the tic tac toe board with an x axis and y axis and i can access each square to find out whether there is an X or an O. I have absolutely no idea how to do this in python and I really, really, don't want

Re: Is it possible to use multidimensional arrays ?

2009-06-06 Thread bearophileHUGS
pdlem...@earthlink.net, if you are using Psyco and you aren't using NumPy and you want max speed you may use: NROWS = 24 NCOLS = 75 screen = array("H", [0]) * (NROWS * NCOLS) and then you can use items like this: screen[r * NCOLS + c] (If NCOLS is equal or a bit lower than a power of 2 it's bette

Re: Is it possible to use multidimensional arrays ?

2009-06-06 Thread Robert Kern
On 2009-06-06 14:48, pdlem...@earthlink.net wrote: All attempts have failed. import WConio import array screen = array.array('H',[0]*75,[0]*24) ERR array takes at most 2 arguments screen = array.array('H',[0]*75[0]*24)

Re: Is it possible to use multidimensional arrays ?

2009-06-06 Thread kj
In pdlem...@earthlink.net writes: >All attempts have failed. >import WConio >import array >screen = array.array('H',[0]*75,[0]*24) > ERR array takes at most 2 arguments >screen = array.array('H',[0]*75[0]*24) >T

Is it possible to use multidimensional arrays ?

2009-06-06 Thread pdlemper
All attempts have failed. import WConio import array screen = array.array('H',[0]*75,[0]*24) ERR array takes at most 2 arguments screen = array.array('H',[0]*75[0]*24) TypeErr int object is unsubscriptable

Re: multidimensional "arrays"

2007-12-06 Thread Jeremy Sanders
Horacius ReX wrote: > do you know how to do similar but in two dimensions ? Investigate the numpy module if you are dealing with numbers. Jeremy -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: multidimensional "arrays"

2007-12-06 Thread Remco Gerlich
Hi, DATA = [ [ 0 for i in range(ncolumns) ] for i in range(nrows) ] Is one way. DON'T do it like this: row = [0] * ncolumns data = [ row ] * nrows # WRONG! Since after that, every row is the exact same object; if you set data[0][0] = 1, the first element of _every_ row is 1. But I guess you a

Re: multidimensional "arrays"

2007-12-06 Thread bearophileHUGS
Horacius ReX: > do you know how to do similar but in two dimensions ? >>> nr = 3 >>> nc = 4 >>> [[None] * nc for _ in xrange(nr)] [[None, None, None, None], [None, None, None, None], [None, None, None, None]] Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

multidimensional "arrays"

2007-12-06 Thread Horacius ReX
in python, when I want to use arrays, I follow this way; DATA = [0] * nint and when I want to use I do; DATA[i] = do you know how to do similar but in two dimensions ? thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: numpy : argmin in multidimensional arrays

2006-07-06 Thread TG
thanks. unravel_index do the trick. Travis E. Oliphant wrote: > TG wrote: > > Hi there. > > > > I am working with multi-dimensional arrays and I need to get > > coordinates of the min value in it. > > > > using myarray.argmin() returns the index in the flatten array, which is > > a first step, but

Re: numpy : argmin in multidimensional arrays

2006-07-06 Thread Travis E. Oliphant
TG wrote: > Hi there. > > I am working with multi-dimensional arrays and I need to get > coordinates of the min value in it. > > using myarray.argmin() returns the index in the flatten array, which is > a first step, but I wonder if it is possible to get the coordinates > directly as an array, ra

numpy : argmin in multidimensional arrays

2006-07-06 Thread TG
Hi there. I am working with multi-dimensional arrays and I need to get coordinates of the min value in it. using myarray.argmin() returns the index in the flatten array, which is a first step, but I wonder if it is possible to get the coordinates directly as an array, rather than calculating them

Re: Multidimensional arrays - howto?

2005-02-16 Thread Colin J. Williams
[EMAIL PROTECTED] wrote: Hello all, I am trying to convert some C code into python. Since i am new to python, i would like to know how to deal with multidimensional arrays? Thanks, -Joe Here's a snippet of what i am trying to convert: # define table0 15 # define table1 20 unsigned int Table[t

Re: Multidimensional arrays - howto?

2005-02-14 Thread Fredrik Lundh
<[EMAIL PROTECTED]> wrote: > I am trying to convert some C code into python. Since i am new to > python, i would like to know how to deal with multidimensional arrays? http://www.python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list might be helpful.

Re: Multidimensional arrays - howto?

2005-02-14 Thread Daniel Yoo
[EMAIL PROTECTED] wrote: : Hello all, : I am trying to convert some C code into python. Since i am new to : python, i would like to know how to deal with multidimensional arrays? Here you go: http://python.org/doc/faq/programming.html#how-do-i-create-a-multidimensional-list Also, if your

Multidimensional arrays - howto?

2005-02-14 Thread doodle4
Hello all, I am trying to convert some C code into python. Since i am new to python, i would like to know how to deal with multidimensional arrays? Thanks, -Joe Here's a snippet of what i am trying to convert: # define table0 15 # define table1 20 unsigned int Table[table0][table1] if(