Gabriel Genellina wrote: > On 12 dic, 17:46, "George Sakkis" <[EMAIL PROTECTED]> wrote: > > > I wonder if the following is possible: > > > > def inject_n_call(func, **kwds): > > '''Call func by first updating its locals with kwds.''' > > > > def f(): > > return x*y > > > > >>> eval(f.func_code, dict(x=3,y=4)) > 12
Sweet! I think I just reinvented what eval does in this case by fiddling with sys.settrace and frame.f_globals. Glad to trash my 20-line function for an one-liner :) Regards, George -- http://mail.python.org/mailman/listinfo/python-list