2D lists

Alan James Salmoni alan_salmoni at yahoo.com
Tue Jan 21 06:12:10 EST 2003


Marcin Matuszkiewicz <marcin at finisar.com> wrote in message news:<hVadnXEIxLEWw7GjXTWc-w at speakeasy.net>...
> What is a most efficient way to create an intialized 2D list?
> 

a = [0] * 3
b = []
b.append(a)
b.append(a)

or:

c = [[0]*3,[0]*3]

Unless of course you use the Numeric extension:

a = Numeric.zeros((3,2))

Much easier!

Alan.
SalStat Statistics: http://salstat.sunsite.dk




More information about the Python-list mailing list