On Tue, Nov 12, 2002 at 07:20:12PM +0000, Michael Hudson wrote:
"Patrick K. O'Brien"
writes: On Tuesday 12 November 2002 11:06 am, Steve Waterbury wrote:
Twisted Gurus:
Not yet, but I'd like to be one day. ;-)
I'm using the "curry" recipe from the Python Cookbook (pretty much verbatim), and it appears to work fine in my code, but cPickle isn't happy about it:
The short answer is that Python doesn't currently pickle nested class and fucntion objects, i.e. those not defined at the top level of the module.
Unless something's changed since I last looked, you can't pickle functions at all.
def foo(): ... pass ... import cPickle cPickle.dump(foo, open('testpickle', 'w')) bar = cPickle.load(open('testpickle'))
I'd imagine this would work in most versions of python, given that people have been pickling objects for countless generations.