[Python-Dev] 2.4a2, and @decorators (original) (raw)

Guido van Rossum guido at python.org
Tue Aug 3 16:04:38 CEST 2004


Here's a brief test for a syntax-change-less implementation of this feature, not as complete as testdecorators, but a good start, I believe:

[fast forward to syntax example]

decorate(staticmethod) def bar(x): print x

decorate(classmethod) def baz(cls, y): print cls, y

I'm speechless. If the ambiguous

[classmethod]
def foo(x):
    ...

is rejected because it doesn't look like it does something to foo, how come there's suddenly a crop of solutions that have the same problem being proposed? What you write looks like a call to the function decorate(), followed by a function method definition. The "action-at-a-distance" that is presumed by the decorate() call is difficult to explain and a precedent for other worse hacks. Its only point in favor seems to be that it doesn't use '@'.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list