Skip to content

Instantly share code, notes, and snippets.

@dev4Fun
Created February 7, 2020 04:04
Show Gist options
  • Select an option

  • Save dev4Fun/69b6465810a55c53eec551f1872d6af6 to your computer and use it in GitHub Desktop.

Select an option

Save dev4Fun/69b6465810a55c53eec551f1872d6af6 to your computer and use it in GitHub Desktop.
# 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