Skip to content

Instantly share code, notes, and snippets.

@djtriptych
Created November 30, 2012 00:01
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 djtriptych/4172781 to your computer and use it in GitHub Desktop.
Save djtriptych/4172781 to your computer and use it in GitHub Desktop.
python clear hack
# saran = clear wrap. get it?
def saran(f):
def g(*args, **kwargs):
d = f(*args, **kwargs)
try:
_clear = d.pop('clear')
except KeyError:
return d
d['clear'] = _clear
return d
return g
vars = saran(vars)
locals = saran(locals)
globals = saran(globals)
del saran
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment