Here you go. Unfortunate that you can't modify locals() easily, but there are other options. def foo(d): for k in d: exec '%s = %s' % (k, repr(d[k])) print a + b foo({'a':1, 'b':2})