Skip to content

Instantly share code, notes, and snippets.

@DanielOaks
Created November 10, 2016 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielOaks/84282a58fbceeb313afbbd09ab974c4b to your computer and use it in GitHub Desktop.
Save DanielOaks/84282a58fbceeb313afbbd09ab974c4b to your computer and use it in GitHub Desktop.
class DataStore:
def __init__():
self.store = {}
def set(key, value):
self.store[key] = value
def delete(key):
try:
del self.store[key]
except:
pass
def load(filename):
raise Exception("Method must be overwritten")
def save(filename):
raise Exception("Method must be overwritten")
class JsonDataStore(DataStore):
def load(filename):
# whoo loading stuff yay
self.store = json.loads(open(filename).read())
def save(filename):
# whoo saving
blah blah blah
class PickleDataStore(DataStore):
def load(filename):
# whoo loading stuff yay
blah blah
def save(filename):
# whoo saving
blah blah blah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment