Re: Decorators, with optional arguments

2010-07-02 Thread Stephen Hansen
On 7/2/10 11:58 AM, Alf P. Steinbach /Usenet wrote: > > #Py3 I'm stuck on Python 2.x, as I mentioned (albeit only in a comment). That said this code does not seem to be including any Py3isms that aren't compatible. > class Thing(object): > @expose() > def test1(self, arg1): > re

Re: Decorators, with optional arguments

2010-07-02 Thread Stephen Hansen
On 7/2/10 11:55 AM, Thomas Jollans wrote: > Looks good! You may still want to use functools.update_wrapper or > functools.wraps on "wrap". Are you sure? I've been doing a little bit of experimentation and I only did the 'wraps' on that inner function, because it seemed that it was all that was nee

Re: Decorators, with optional arguments

2010-07-02 Thread Carl Banks
On Jul 2, 10:41 am, Stephen Hansen wrote: > Okay, so! > > I actually never quite got around to learning to do deep and useful > magic with decorators. I've only ever done the most basic things with > them. Its all been a little fuzzy in my head: things like what order > decorators end up being cal

Re: Decorators, with optional arguments

2010-07-02 Thread Alf P. Steinbach /Usenet
* Stephen Hansen, on 02.07.2010 19:41: Okay, so! I actually never quite got around to learning to do deep and useful magic with decorators. I've only ever done the most basic things with them. Its all been a little fuzzy in my head: things like what order decorators end up being called in if the

Re: Decorators, with optional arguments

2010-07-02 Thread Nathan Rice
I like to think of decorators with arguments as decorator factory functions. I try and unroll them as much as possible... I have some decorators that work like so (and please note that the wraps and returns_as_output are separate so that I can mutate the behavior as needed, if you just wanted a si

Re: Decorators, with optional arguments

2010-07-02 Thread Thomas Jollans
On 07/02/2010 07:41 PM, Stephen Hansen wrote: > Okay, so! > > I actually never quite got around to learning to do deep and useful > magic with decorators. I've only ever done the most basic things with > them. Its all been a little fuzzy in my head: things like what order > decorators end up being

Decorators, with optional arguments

2010-07-02 Thread Stephen Hansen
Okay, so! I actually never quite got around to learning to do deep and useful magic with decorators. I've only ever done the most basic things with them. Its all been a little fuzzy in my head: things like what order decorators end up being called in if there's more then one, etc. But in my