[Python-Dev] Re: Decorators: vertical bar syntax (original) (raw)
Gregory Lielens gregory.lielens at fft.be
Sun Aug 8 13:08:30 CEST 2004
- Previous message: [Python-Dev] Re: Decorators: vertical bar syntax
- Next message: [Python-Dev] Re: Decorators: vertical bar syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I just anted to rewrite those "real-life-looking" examples with my proposed '%' syntax:
def foo() % (classmethod, accepts(int,int), returns(float),): or formatted: def foo() % ( classmethod, accepts(int,int), returns(float),): Or it can be done the this way: def foo(): ... foo %= (classmethod, accepts(int,int), returns(float),) The operation could be called "decorative apply", if the LHS has call attribute. Just a new form of % operation with special syntax for "def" operator.
Sincerely yours, Roman Suzi
Yes, you should add this proposal in the wiki (http://www.python.org/cgi-bin/moinmoin/PythonDecorators) just after "C3. tuple-after-def syntax with a (pseudo-)keyword". Your idea is basically the same with a % instead of a pseudo-keyword... For me, +1 for these two (and your justification for using % is convincing for me, especially as it is difficult to agree on a best choice for the pseudo-keyword to use in C2, C3 so you are my current favorite ;-))
Having followed the thread, my own summary (that didn't change much these last days) is that all before-def variants are prefered because it is more aesthetically pleasing (I do not agree ;-) ) and it is more related to the "exterior" behavior of the function/method (i.e. seen from the caller perspective) than to it's internal behavior (i.e. seen from the implementer of the function, or when examining function algorithm). This last argument is nice and made me re-evaluate my gut feeling, but in the end it was not sufficient for changing my preference for the various C proposal (with C3 and yours beeing my favorites). Indeed, adding decorators (or any modifier/metadata) in front of a declaration is a valid way to proceed of course, but feel not in line with the rest of python syntax, and that is what bother me the most, it feel too much like an ad-hoc special casing...And anyway, function/method name and arguments are at least as important as decorator from a caller perspective, which for me mitigate a lot the argument that decorators should be in front: In a C++ like syntax, yes, sure, but with Python syntax it does not fit well in the general picture imho...
Maybe I'll change my mind after a while, if before-def syntax is adopted, but for this it would help if this type of construct could be used not only for decorators (and with | instead of @ - pleaaase ;-) ), so that "special case" does not flash into my head each time I see it ;-)
Regards,
Greg.
- Previous message: [Python-Dev] Re: Decorators: vertical bar syntax
- Next message: [Python-Dev] Re: Decorators: vertical bar syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]