[Python-Dev] Decorators with arguments are curries!
Andrew Durdin
adurdin at gmail.com
Sat Aug 7 15:13:50 CEST 2004
More information about the Python-Dev mailing list
Sat Aug 7 15:13:50 CEST 2004
- Previous message: [Python-Dev] Decorators with arguments are curries!
- Next message: [Python-Dev] Decorators with arguments are curries!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, 07 Aug 2004 15:00:13 +0200, "Martin v. Löwis" <martin at v.loewis.de> wrote: > Andrew Durdin wrote: > > > > Here the first decorator statement is bare, while the second one > > includes parentheses and an argument; the first one looks like a > > function reference, while the second looks like a function call. > > Correct. And that is indeed the intended meaning. Did you try this > out? It gives > > Traceback (most recent call last): > File "b.py", line 9, in ? > @foo_decorator > TypeError: bar_decorator() takes exactly 2 arguments (1 given) > > (although, as you can see, the line number is off by one) > > See > > http://www.python.org/dev/doc/devel/ref/function.html > > on why this is so. Ah! Quite so. The relevant quote would be: "The result [of the decorator expression] must be a callable, which is invoked with the function object as the only argument". I guess I didn't pay quite enough attention to the examples in PEP 318 to understand them properly :)
- Previous message: [Python-Dev] Decorators with arguments are curries!
- Next message: [Python-Dev] Decorators with arguments are curries!
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list