Created
September 1, 2011 13:29
-
-
Save fvbock/1186164 to your computer and use it in GitHub Desktop.
clean up the globals to an initial state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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