Created
August 2, 2008 06:21
-
-
Save jeremyBanks/3720 to your computer and use it in GitHub Desktop.
A simple example of how the Pickle module can be used.
This file contains 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
#!/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