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 > It's much simpler not to use the decorator syntax if you also want access to the original function.
Simply declare f as a function, then assign decorator(f) to some other name. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Blog of Note: http://holdenweb.blogspot.com See you at PyCon? http://us.pycon.org/TX2007 -- http://mail.python.org/mailman/listinfo/python-list