Skip to content

Instantly share code, notes, and snippets.

@tomotaka
Created June 16, 2012 08:54
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 tomotaka/2940574 to your computer and use it in GitHub Desktop.
Save tomotaka/2940574 to your computer and use it in GitHub Desktop.
callable can be pickled
import pickle
def hoge(n):
n2 = n * 2
print "this is hoge, n*2=%d" % n2
s_hoge = pickle.dumps(hoge)
loaded_hoge = pickle.loads(s_hoge)
loaded_hoge(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment