marshal and code objects
Tue, 5 Apr 94 11:32:47 EDT

Is there anyway to assign a code object to a function or method in

If not why are code objects supported as a valid type that can be
packed up using the marshal module in python?

if I have:

>>> import marshal

>>> def gru(*args):
... print args

>>> marshalledFunc = marshal.dumps(gru.func_code)

>>> reclaimedFunc = marshal.loads(marshalledFunc)

I can ask if "gru.func_code == reclaimedFunc" and python says you bet,
but I can't then assign reclaimedFunc to any object to get a new
function with the same functionality as gru. (because gru.func_code is
read only).



Richard Stoakley "It's never to late to have a pleasant childhood!"
University of Virginia