Created
August 21, 2012 18:00
-
-
Save igorgue/3417921 to your computer and use it in GitHub Desktop.
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 | |
import pickle | |
def pow2(number): | |
return number * number | |
if __name__ == '__main__': | |
# Serializing (you could also save this to a file) | |
serialized_value = pickle.dumps(pow2) | |
# The value is now 'kfiom4pow2m49' ... some random crap (serialized value) | |
print('Value now is: {0}'.format(serialized_value)) | |
# Desirializing | |
pow3 = pickle.loads(serialized_value) | |
# Is gonna be 4 | |
print('pow3(2) = {0}'.format(pow3(2))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment