Skip to content

Instantly share code, notes, and snippets.

@igorgue
Created August 21, 2012 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igorgue/3417921 to your computer and use it in GitHub Desktop.
Save igorgue/3417921 to your computer and use it in GitHub Desktop.
#!/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