Duncan Booth wrote:
> Fuzzyman wrote:
[snip..]
>
> Does this do what you wanted? Instead of messing about with the code object
> just work out which values from the namespace the function actually
> expects.
>
> >>> def callfromnamespace(fn, namespace):
> names = fn.func_code.co_varnames[:fn.f
Simon Forman wrote:
> Fuzzyman wrote:
[snip..]
> > I was hoping I could get to the code object for the *body* of the
> > function. Looks like that won't be possible without dis-assembling the
> > bytecode or other tricks even more hackish than what I've already done.
> >
> > For the record, the co
Fuzzyman wrote:
>> I'd like to construct the code object so that it takes the parameters
>> from the enclosing scope (the context I pass into exec I guess),
>> without clobbering any local variables that may be defined in the code
>> object.
>>
>> Anyone got any clues ?
Does this do what you want
Fuzzyman wrote:
> Fuzzyman wrote:
> > Fuzzyman wrote:
> > > Hello all,
> > >
> > > I'm trying to extract the code object from a function, and exec it
> > > without explicitly passing parameters.
> > >
> > > The code object 'knows' it expects to receive paramaters. It's
> > > 'arg_count' attribute i
Fuzzyman wrote:
> Fuzzyman wrote:
> > Hello all,
> >
> > I'm trying to extract the code object from a function, and exec it
> > without explicitly passing parameters.
> >
> > The code object 'knows' it expects to receive paramaters. It's
> > 'arg_count' attribute is readonly.
> >
> > How can I set
Fuzzyman wrote:
> Hello all,
>
> I'm trying to extract the code object from a function, and exec it
> without explicitly passing parameters.
>
> The code object 'knows' it expects to receive paramaters. It's
> 'arg_count' attribute is readonly.
>
> How can I set the arg_count to 0, or pass paramet