newbie : array initialization, anyone ?

Alex Martelli aleaxit at yahoo.com
Wed Dec 27 15:37:30 EST 2000


<arcege at shore.net> wrote in message
news:wgr26.1691$JG.213419 at news.shore.net...
    [snip]
> This is in the FAQ (#4.50).  You will want to create each inner dimension
> individually:
>
> >>> multidim = [ None ] * 3
> >>> for i in range(3):
> ...   multidim[i] = [ 0 ] * 10

Or, more compactly, in Python 2:

>>> mudi = [ [0]*10 for i in range(3) ]

Not sure if the FAQ shows this handy list-comprehension use...?


Alex







More information about the Python-list mailing list