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 recent call
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 stdin, line 1, in module
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
...
function = type(f)
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:
eval(f(1,1), {f:f, k:1})
Or even better, something like:
def g(k):
return f
g(1)(1,1) == 3
Regards,
Quoth =?ISO-8859-1?Q?Juan_Pablo_Romero_M=E9ndez?= jpablo.rom...@gmail.com:
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:
eval(f(1,1), {f:f,
P
2008/12/16 rdmur...@bitdance.com:
Quoth =?ISO-8859-1?Q?Juan_Pablo_Romero_M=E9ndez?= jpablo.rom...@gmail.com:
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