Decorator syntax

Mark Bottjer mark_bottjer at hotmail.com
Fri Aug 6 19:19:40 EDT 2004


Ames Andreas (MPA/DF) wrote:
> Michael Ekstrand wrote:
>>def(staticmethod) somemethod(self, args):
>>    some code
> 
> could you or someone else please enlighten me, as someone who wasn't
> following the decorator syntax discussion, why this syntax was ruled
> out?

I can give *a* reason, though it may have little to do with the actual 
reasoning used by the powers that be. :)

Something similar was proposed way back when print>> was introduced. 
Some asked: "why not use 'print(f) arg, arg, ...' instead of this ugly 
print>>f hack?" The answer was simple: print is a statement, not a 
function, and statement names don't take arguments.

def is also a statement (as is class). "Calling" it, as putting an 
argument list after it implies, makes no sense to me. I would be 
perfectly comfortable with this syntax if it were a function, but it 
just doesn't seem to fit with a statement.

   -- Mark



More information about the Python-list mailing list