Arnaud Delobelle schrieb:
> It's a FAQ:
> http://www.python.org/doc/faq/programming/#how-do-i-create-a-multidimensional-list
Somewhere on my todo list I have "read through the whole Python FAQ",
but so far never got round doing it. Should probably set it to prio A.
-- Christoph
--
http://mail.p
Steve Turner wrote:
> I finally decided to have a go with Python and am working through the
> tutorial.
Great!
> On my old BBC Computer [...]
These were nice machines...
> In Python I thought I could do this with:
>
> >>> a=[0,0,0]
> >>> b=[a,a,a]
> >>> b
> [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
>
[EMAIL PROTECTED] wrote:
> is there a better way of creating d??
a = [[0] * 3 for dummy in xrange(3)]
>> Each element of a refers to a distinct array.
>>
>>> Why not simply [[0]*3]*3 ?
>> All three elements of the result refer to the same array.
>
> ... whereas you reassign all three elem
> >>> is there a better way of creating d??
>
> >> a = [[0] * 3 for dummy in xrange(3)]
>
> Each element of a refers to a distinct array.
>
> > Why not simply [[0]*3]*3 ?
>
> All three elements of the result refer to the same array.
... whereas you reassign all three elements of [0]* 3.
>>> ((0,)
Christoph Zwerschke wrote:
> Marc 'BlackJack' Rintsch schrieb:
>> On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote:
>>
>>> Apart from doing something like
>>> a=[0,0,0]
>>> b=[0,0,0]
>>> c=[0,0,0]
>>> d=[a,b,c]
>>>
>>> is there a better way of creating d??
>>
>> a = [[0] * 3 for dummy in xran
"Christoph Zwerschke" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
| Marc 'BlackJack' Rintsch schrieb:
| > On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote:
| >
| >> Apart from doing something like
| >> a=[0,0,0]
| >> b=[0,0,0]
| >> c=[0,0,0]
| >> d=[a,b,c]
| >>
| >> is there
On Sun, 02 Mar 2008 21:58:31 +0100, Christoph Zwerschke wrote:
> Marc 'BlackJack' Rintsch schrieb:
>> On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote:
>>
>>> Apart from doing something like
>>> a=[0,0,0]
>>> b=[0,0,0]
>>> c=[0,0,0]
>>> d=[a,b,c]
>>>
>>> is there a better way of creating d?
Christoph Zwerschke wrote:
: Marc 'BlackJack' Rintsch schrieb:
:: On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote:
::
::: Apart from doing something like
::: a=[0,0,0]
::: b=[0,0,0]
::: c=[0,0,0]
::: d=[a,b,c]
:::
::: is there a better way of creating d??
::
:: a = [[0] * 3 for dummy in
Marc 'BlackJack' Rintsch schrieb:
> On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote:
>
>> Apart from doing something like
>> a=[0,0,0]
>> b=[0,0,0]
>> c=[0,0,0]
>> d=[a,b,c]
>>
>> is there a better way of creating d??
>
> a = [[0] * 3 for dummy in xrange(3)]
Why not simply [[0]*3]*3 ?
--
Marc 'BlackJack' Rintsch wrote:
: On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote:
:
:: Apart from doing something like
:: a=[0,0,0]
:: b=[0,0,0]
:: c=[0,0,0]
:: d=[a,b,c]
::
:: is there a better way of creating d??
:
: a = [[0] * 3 for dummy in xrange(3)]
Thanks, Marc.
--
Steve
--
On Sun, 02 Mar 2008 14:15:09 +, Steve Turner wrote:
> Apart from doing something like
> a=[0,0,0]
> b=[0,0,0]
> c=[0,0,0]
> d=[a,b,c]
>
> is there a better way of creating d??
a = [[0] * 3 for dummy in xrange(3)]
Ciao,
Marc 'BlackJack' Rintsch
--
http://mail.python.org/mailman/list
I finally decided to have a go with Python and am working through the
tutorial.
On my old BBC Computer I could do something like this:
DIM A(2,2)
to create a 3 by 3 array of data. Then I could set any point:
A(0,0) = foo
A(0,1) = bar
etc.
In Python I thought I could do this with:
>>> a=[0,0,
12 matches
Mail list logo