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 parameters to the code object
when I exec it ?
.... print x
....
<type 'code'>
Traceback (most recent call last):
File "<input>", line 1, in ?
TypeError: f() takes exactly 1 argument (0 given)
1
Traceback (most recent call last):
File "<input>", line 1, in ?
TypeError: readonly attribute
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
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 parameters to the code object
when I exec it ?
>>def f(x):
....
>>c = f.func_code
>>type(c)
>>type(c)
>>exec c
File "<input>", line 1, in ?
TypeError: f() takes exactly 1 argument (0 given)
>>c.co_argcou nt
>>c.co_argcou nt = 0
File "<input>", line 1, in ?
TypeError: readonly attribute
>>>
http://www.voidspace.org.uk/python/index.shtml
Comment