Created
November 18, 2019 16:42
-
-
Save lhk/996100c444242f9efdf7fb403204d795 to your computer and use it in GitHub Desktop.
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
import shelve | |
def save_scope(session_id='default'): | |
filename = f'/tmp/{session_id}.out' | |
shelf = shelve.open(filename, 'n') | |
for name in dir(): | |
try: | |
shelf[name] = globals()[name] | |
except Exception as e: | |
pass | |
shelf.close() | |
def load_scope(session_id='default'): | |
filename = f'/tmp/{session_id}.out' | |
shelf = shelve.open(filename) | |
for name in shelf: | |
globals()[name] = shelf[name] | |
shelf.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment