marshal and code objects

rws2v@henson.cs.virginia.edu
Tue, 5 Apr 94 11:32:47 EDT

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

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).

thanks,

stoakley

-------------------------------------------------------------------------------
Richard Stoakley
rws2v@virginia.edu "It's never to late to have a pleasant childhood!"
University of Virginia