Skip to content

Instantly share code, notes, and snippets.

@jeremyBanks
Created August 2, 2008 06:21
Show Gist options
  • Save jeremyBanks/3720 to your computer and use it in GitHub Desktop.
Save jeremyBanks/3720 to your computer and use it in GitHub Desktop.
A simple example of how the Pickle module can be used.
#!/usr/bin/env python
class Character(object):
"""Crude example."""
me = Character()
me.name = "God"
me.stats = [1, 2, 3, 4, 5]
import pickle
pickle.dump(me, file("me.character", "w"))
del me
me = pickle.load(file("me.character", "r"))
print(me.name)
print(me.stats)
# Prints:
# God
# [1, 2, 3, 4, 5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment