Skip to content

Instantly share code, notes, and snippets.

@Torxed
Created June 27, 2014 06:26
Show Gist options
  • Save Torxed/ba0fd5b0dc1eae82cea6 to your computer and use it in GitHub Desktop.
Save Torxed/ba0fd5b0dc1eae82cea6 to your computer and use it in GitHub Desktop.
import pickle
gameVars = {'health' : 100, 'stamina' : 100} # 100% on both
print('Current health is:', gameVars['health'])
gameVars['health'] -= 25
pickle.dump(gameVars, open('game.dump', 'wb'))
del(gameVars)
try:
print('Current health is:', gameVars['health'])
except:
print('Could not print, game variables are deleted...')
gameVars = pickle.load(open('game.dump', 'rb'))
print('Current health is:', gameVars['health'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment