As in Python everythong is an object you could use __name__. >>> import cPickle >>> def def1(): ... pass >>> def def2(): ... pass >>> def1.__name__ def1 >>> def2.__name__ def2
in this case you can combine __name__ to get the object name and then combine it with eval to pickle. >>> pickleString = "stored = cPickle.dumps(" + def1.__name__ + ")" >>> eval(pickleString) >>> restored = cPickle.loads(stored) in this way you deal with dynamic strings and you can pickle anything -- http://mail.python.org/mailman/listinfo/python-list