exec and CodeObjects
Prepscius, Colin (IT)
Colin.Prepscius at morganstanley.com
Fri Jul 20 11:48:05 EDT 2007
Does anybody know how to pass parameters to 'exec
somefunction.func_code'?
def f1():
print 'this is f1'
def f2(p):
print 'this is f2, p =', str(p)
exec f1.func_code
THIS RESULTS IN: "this is nf1" WHICH IS NICE
exec f2.func_code
THIS RESULTS IN: TypeError: f2() takes exactly 1 argument (0 given)
WHICH IS EXPECTED
exec f2.func_code in {'p':34}
THIS RESULTS IN: TypeError: f2() takes exactly 1 argument (0 given)
?????
Why? So I can take a function defined in a script or repl and a
parameter, marshal them, send the results to a remote host, unmarshal
them, and execute the function given the parameter. Am I going about
this wrongly? I'd specifically like to avoid having to save the
function in a file, send the file and import it on the remote side.
thanks!
Colin
--------------------------------------------------------
NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070720/351176e3/attachment.html>
More information about the Python-list
mailing list