Juan Pablo Romero Méndez wrote:
> The hack given by Peter works fine, except in this case:
>
def (fn):
> ... f2 = lambda x,y:(x,y,fn(x,y))
> ... function = type(f2)
> ... f3 = function(f2.func_code,dict())
> ... print f3
> ...
(lambda x,y:x+y)
> Traceback (most r
The hack given by Peter works fine, except in this case:
>>> def (fn):
... f2 = lambda x,y:(x,y,fn(x,y))
... function = type(f2)
... f3 = function(f2.func_code,dict())
... print f3
...
>>> (lambda x,y:x+y)
Traceback (most recent call last):
File "", line 1, in
File "",
Juan Pablo Romero Méndez wrote:
> Suppose this function is given:
>
> def f(x,y):
> return x+y+k
>
>
> Is it possible to somehow assign a value to k without resorting to
> making k global?
You can replace the function's global dictionary:
>>> def f(x, y):
... return x+y+k
...
>>> functi
P
2008/12/16 :
> Quoth "=?ISO-8859-1?Q?Juan_Pablo_Romero_M=E9ndez?=" :
>> Hello,
>>
>> Suppose this function is given:
>>
>> def f(x,y):
>> return x+y+k
>>
>> Is it possible to somehow assign a value to k without resorting to
>> making k global?
>>
>> I'm thinking something like this:
>>
>> eva