Pickling a staticmethod in Python
问题 I've been trying to pickle an object which contains references to static class methods. Pickle fails (for example on module.MyClass.foo ) stating it cannot be pickled, as module.foo does not exist. I have come up with the following solution, using a wrapper object to locate the function upon invocation, saving the container class and function name: class PicklableStaticMethod(object): """Picklable version of a static method. Typical usage: class MyClass: @staticmethod def doit(): print "done"