Avoiding `exec', how to?
François Pinard
pinard at iro.umontreal.ca
Thu May 30 15:24:39 EDT 2002
Hi, my fellow snakes :-).
I do not like using `exec', and wonder if there is a way to avoid it in:
# Fabriquer une variable globale pour chaque élément de DEFS.
for name, value in defs.__dict__.items():
if name[0] != '_':
# J'aimerais bien éviter `exec'...
exec '%s = %s' % (name, repr(value))
del defs, name, value
The goal here is to initialise one global variable per item in DEFS,
preserving the item name and value in each.
--
François Pinard http://www.iro.umontreal.ca/~pinard
More information about the Python-list
mailing list