Actually, thx to Gabrielle Genellina, who wrote earlier: Instead of using exec, rebuild a new function from the unmarshalled code:
import new f3 = new.function(f2.func_code, globals()) f3(parameter) I haven't tried it yet, but will today... -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] On Behalf Of Carsten Haese Sent: Tuesday, July 24, 2007 1:39 PM To: python-list@python.org Subject: Re: exec and func_code On Tue, 2007-07-24 at 13:24 -0400, Prepscius, Colin (IT) wrote: > 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 not just "f2(34)"? What problem are you trying to solve here? -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list -------------------------------------------------------- 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. -- http://mail.python.org/mailman/listinfo/python-list