Created
September 14, 2011 20:36
-
-
Save mattyw/1217714 to your computer and use it in GitHub Desktop.
Python Shelving
This file contains hidden or 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
def add(x, y): | |
return x + y | |
def subtract(x, y): | |
return x - y | |
import shelve | |
d = shelve.open('shelve_state.dat') | |
d['add'] = add | |
d['subtract'] = subtract | |
func = d['add'] | |
print func(3,5) | |
func = d['subtract'] | |
print func(5, 1) | |
d.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment