eval ?

Angelo Secchi secchi at sssup.it
Fri Feb 20 06:56:57 EST 2004


I'm trying to use eval (is the right function? ) to generate empty lists
with different names(es. list_1, list_2, list_3, ...) in a loop similar
to:

for index in range(1,4):
	list=[]
	for index in range(1,7):
		if <condition>:
			list.append(1)
	foo='list_'+str(index)+'=list'
	eval(foo)

I am not a programmer as you probably see from the code and I do not
even know if this is the right approach to do that in Python (I used
this structure with Matlab that I want now to dismiss ...)

Any help?
Thanks
angelo




More information about the Python-list mailing list