Skip to content

Instantly share code, notes, and snippets.

@felipecruz
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felipecruz/09c6bf530aad32368bab to your computer and use it in GitHub Desktop.
Save felipecruz/09c6bf530aad32368bab to your computer and use it in GitHub Desktop.
Bind in outer scope variables from a dict
def bind_local_names(params):
'''create outer scope vars from a dict'''
import sys
for k, v in params.items():
sys._getframe(1).f_locals[k] = v
params = dict(b='test', c=10)
bind_local_names(params)
assert b == 'test'
assert c == 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment