Declaring variables from a list

Pierre Quentel quentel.pierre at wanadoo.fr
Sat Apr 9 03:46:35 EDT 2005


You can use the built-in statement exec 
(http://www.python.org/doc/2.4.1/ref/exec.html) :

# Blob = ['Var1', 'Var2', 'vAR3']
# i = 5
# for listitems in Blob:
#     i += 1
#     exec('%s = i' %listitems)
#
# print Var1, Var2, vAR3

Regards,
Pierre



More information about the Python-list mailing list