Skip to content

Instantly share code, notes, and snippets.

@fvbock
Created September 1, 2011 13:29
Show Gist options
  • Save fvbock/1186164 to your computer and use it in GitHub Desktop.
Save fvbock/1186164 to your computer and use it in GitHub Desktop.
clean up the globals to an initial state
dont_clean = [ 'initial_vars' ]
def cleanup():
print dont_clean
vars_to_free = [ k for k in set( globals().copy() ).difference( initial_vars.union( set( dont_clean ) ) ) ]
print vars_to_free,
for c in vars_to_free:
del globals()[ c ]
print "cleaned"
initial_vars = set( globals().keys() )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment