ActiveState Code

Recipe 574426: Modfying a local __dict__


Works in python 2.4 and 2.5

Python
1
2
3
4
5
6
7
def f(**kw):
    for k,v in kw.iteritems():
        locals()[k]=v
    exec('pass') # apply locals %)
    print x

f(x='test')

Sign in to comment