Is it safe to modify the dict returned by vars() or locals()

Helmut Jarausch jarausch at
Mon Dec 1 22:01:00 CET 2008


I am looking for an elegant way to solve the following problem:

Within a function

def Foo(**parms)

I have a list of names, say  VList=['A','B','C1']
and I like to generate abbreviation
_A identical to parms['A']

for that I could write

def Foo(**parms) :
   for N in VList :
     if  N in parms :
       vars()[N]= parms[N]
     else :
       vars()[N]= None

Does this work, is it typical Python?

Many thanks for a hint,

Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany

More information about the Python-list mailing list