[Python-Dev] method decorators (PEP 318)
Phillip J. Eby
pje at telecommunity.com
Fri Mar 26 12:56:43 EST 2004
At 11:32 AM 3/26/04 -0600, Skip Montanaro wrote:
>Using the proposed decorator syntax with the decorator after the arglist
>with a little judicious indentation I can make it look sort of like what
>you're after:
>
> def foobar(self, arg) [attributes(
> author = "Guido van Rossum"
> deprecated = True
> )]:
> pass
Thinking about it a bit more, I can now explain why I see a problem with
creating a second syntax for function attributes. It has seemed to me the
unwritten rule of Python is:
* Never create syntax if a builtin will do
* Never create a builtin if a stdlib module will do
and so on. A decorator syntax can trivially support function attributes,
but not the other way around. Arguing that they should have a different
spelling seems therefore to be a purity vs. practicality argument.
At the same time, I realize Python also generally prefers to have different
syntax for different use cases. But, how different are these use cases,
really? They're all changing the function in some way.
It's apparent Guido doesn't agree; I just wish I knew what was bothering
him about the PEP, so I could either provide a convincing counterargument,
or understand better why I'm wrong. <0.5 wink> At the moment, I'm worried
that something in my actual use cases will scare him into rejecting the PEP
altogether. <0.01 wink>
More information about the Python-Dev
mailing list