[Python-Dev] Re: Decorator order implemented backwards? (original) (raw)
James Y Knight foom at fuhm.net
Mon Aug 16 06:38:06 CEST 2004
- Previous message: [Python-Dev] Re: Decorator order implemented backwards?
- Next message: [Python-Dev] Re: Decorator order implemented backwards?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Aug 15, 2004, at 11:45 PM, Jack Diederich wrote:
My patch to add support for class decorators defines func before the decorators as a side effect of moving Mark's decorator code out of comfuncdef (and yes, that was a plug).
That's definitely worse. It causes a possibly incorrect temporary value to be bound, even if only for a short amount of time. The current behavior of only doing the store after executing the decorators is cleaner.
I'd rewrite the translation as: """ The following code: @f1(arg) @f2 def func(): return True
is nearly* equivalent to: func = f1(arg)(f2(lambda : True))
- However, you don't have the syntactical restrictions of a lambda, and the function name gets set to "func" instead of "". """
James
- Previous message: [Python-Dev] Re: Decorator order implemented backwards?
- Next message: [Python-Dev] Re: Decorator order implemented backwards?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]