Skip to content

Instantly share code, notes, and snippets.

@nemec
Created Dec 27, 2011
Embed
What would you like to do?
def _as(var, ident):
import inspect
cur_frame = inspect.currentframe()
outer_locals = inspect.getouterframes(cur_frame)[1][0].f_locals
outer_locals[ident] = var
return var
if __name__ == "__main__":
d = ['a', 'b']
if _as(d[0], 'c') is not None:
print c
else:
print "failed"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment