List of lists of lists of lists...
Ángel Gutiérrez Rodríguez
agr at fq.uniovi.es
Mon May 8 06:56:29 EDT 2006
I would like to have a list of lists N times deep, and my solution is (in
pseudocode):
def deep(x):
a=[x]
return a
mylist=[]
for N: mylist=deep(mylist)
Is there a more elegant way to do it?
The maine idea is: from a list having the numbre of steps along N
dimensions, generate a list with an item at each possible point.
Example 1: N=2 list=[2,3] result=[[1,2],[1,2],[1,2]]
Example 2: N=3 list=[3,1,2] result=[[[1,2,3]],[[1,2,3]]]
--
Ángel Gutiérrez Rodríguez - agr at fq.uniovi.es
Instituto de Ciencia de los Materiales de Madrid - CSIC
SpLine - European Syncrothorn Radiation Facility - Grenoble - France
Postal adress: Departamento de Química Física y Analítica
Universidad de Oviedo - c/Julián Clavería 8 33006 - Oviedo
Asturias - Spain
E-mail: agr at fq.uniovi.es Telf.: +34-985103687
More information about the Python-list
mailing list