proposition for syntax for initialisation of multidimensionallists
Erik Max Francis
max at alcyone.com
Tue Oct 12 17:14:50 EDT 2004
"Batista, Facundo" wrote:
> You don't need list comprehensions::
>
> >>> [[[0] * 4] * 3] * 2
> [[[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], [[0, 0, 0, 0], [0, 0, 0,
> 0],
> [0, 0, 0, 0]]]
Yes, you do:
>>> a = [[0] * 3] * 2
>>> a[1][2] = 100
>>> a
[[0, 0, 100], [0, 0, 100]]
--
__ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ I never think of the future. It comes soon enough.
-- Albert Einstein
More information about the Python-list
mailing list