[EMAIL PROTECTED] a écrit : (top-post corrected) > > On 30 Jul 2007 06:17:25 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> > wrote: >> On Sun, 29 Jul 2007 15:22:47 -0700, [EMAIL PROTECTED] wrote: >> >>> I create a variable in a decorator. i want to be able to access that >>> variable in the function to be decorated. How to do this? > >> Pass it as argument to the function: >> >> def deco(func): >> eggs = 42 >> def decorated(*args, **kwargs): >> kwargs['spam'] = eggs >> func(*args, **kwargs) >> return decorated >> >> @deco >> def test(parrot, spam): >> print parrot, spam
> is it possible to do this without passing it as a function argument? What's your use case, exactly ? Having a function depending on a name being set by a decorator is not exactly pythonic, and arguments are meant to pass variables to functions... -- http://mail.python.org/mailman/listinfo/python-list