Matthew Wilson wrote:
> The decorator as_string returns the decorated function's value as
> string. In some instances I want to access just the function f,
> though, and catch the values before they've been decorated.
>
> Is this possible?
>
> def as_string(f):
> def anon(*args, **kwargs):
> y = f(*args, **kwargs)
> return str(y)
> return anon
>
> @as_string
> def f(x):
> return x * x
Untested:
def as_string(f):
def anon(*args, **kwargs):
y = f(*args, **kwargs)
return str(y)
andon.the_function = f
return anon
@as_string
def f(x):
return x * x
print f.the_function(10)
Diez
--
http://mail.python.org/mailman/listinfo/python-list