Created
February 7, 2020 04:04
-
-
Save dev4Fun/69b6465810a55c53eec551f1872d6af6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # store.py | |
| import os | |
| import pickle | |
| from pathlib import Path | |
| persistence_dir = Path(os.path.dirname(os.path.abspath(__file__))) | |
| def read_pickled_set(filename): | |
| path = persistence_dir.joinpath(filename) | |
| if path.exists(): | |
| with open(path, 'rb') as sub_f: | |
| return pickle.load(sub_f) | |
| else: | |
| return set() | |
| def dump_pickled(obj, filename): | |
| path = persistence_dir.joinpath(filename) | |
| with open(path, "wb") as sub_f: | |
| pickle.dump(obj, sub_f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment