[Python-ideas] An easier syntax for writing decorators (& similar things)?

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Oct 8 09:45:31 CEST 2007

Brett Cannon wrote:
> On 10/7/07, Adam Atlas <adam at atlas.st> wrote:
>>def dec(a, b, foo=bar)(func)(*a, **k):
>>     ...stuff...
>>     return func(*a, **k)
> My argument against it is it's ugly and hard to notice. 

I think it's rather elegant in its own way. There's
something exactly analogous in Scheme, where you can

(define (f (g x))

and it gets macro-expanded into the corresponding
nested sequence of lambdas. (The really elegant part
about it in Scheme is that it's not a separate feature --
it just automatically falls out of the way define is
defined in terms of lambda.)

>>I imagine each successive call would
>>return an object something like a partial.

I would implement it by compiling it exactly as
though it were written out as nested defs.


More information about the Python-ideas mailing list