Re: Frame hacking

2006-12-13 Thread fumanchu
George Sakkis wrote: > Actually I thought about this and it would be more convenient in my > case if I could change the "signature" of f to "def f(x,y)" so that I > can pass positional arguments instead of a keywords (don't ask why). > I've tried creating a new code object by tweaking co_varnames,

Re: Frame hacking

2006-12-13 Thread George Sakkis
George Sakkis wrote: > 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(): > > >

Re: Frame hacking

2006-12-12 Thread George Sakkis
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_c

Re: Frame hacking

2006-12-12 Thread Gabriel Genellina
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 -- http://mail.python

Frame hacking

2006-12-12 Thread George Sakkis
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 >>> inject_n_call(f, x=3, y=4) 12 I've been playing with sys.settrace, updating frame.f_locals in the trace function, but it doesn't seem t