[Twisted-Python] Re: pickle apparently doesn't go with curry ...
Patrick K. O'Brien
pobrien at orbtech.com
Wed Nov 13 08:43:08 MST 2002
On Tuesday 12 November 2002 01:20 pm, Michael Hudson wrote:
> "Patrick K. O'Brien" <pobrien at orbtech.com> writes:
> > 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.
Sure you can:
>>> import pickle
>>> pickle.dumps
<function dumps at 0x85f22cc>
>>> p = pickle.dumps(pickle.dumps)
>>> p
'cpickle\ndumps\np0\n.'
>>> dir
<built-in function dir>
>>> p = pickle.dumps(dir)
>>> p
'c__builtin__\ndir\np0\n.'
>>>
--
Patrick K. O'Brien
Orbtech http://www.orbtech.com/web/pobrien
-----------------------------------------------
"Your source for Python programming expertise."
-----------------------------------------------
More information about the Twisted-Python
mailing list