[Python-Dev] Re: Decorator order implemented backwards? (original) (raw)

James Y Knight foom at fuhm.net
Mon Aug 16 06:38:06 CEST 2004


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))

James



More information about the Python-Dev mailing list