[Python-Dev] Why aren't decorators just expressions?

Serhiy Storchaka storchaka at gmail.com
Sat Sep 16 07:22:17 EDT 2017

16.09.17 12:39, Larry Hastings пише:
> So why don't decorators allow arbitrary expressions?  The PEP discusses 
> the syntax for decorators, but that whole debate only concerned itself 
> with where the decorator goes relative to "def", and what funny 
> punctuation might it use.  It never says "decorators shouldn't permit 
> arbitrary expressions because--".  Nor is there any info on wiki page 
> with the extensive summary of alternative syntax proposals.
> Anybody remember?


> I'm not proposing that we allow arbitrary expressions as decorators... 
> well, I'm not doing that /yet/ at least.  But like I said, the syntax 
> has been this way for 13 years and I don't recall anybody complaining.

This may be an argument for not changing the syntax.

Actually I remember somebody raised this question a year or two ago, but 
don't remember details.

More information about the Python-Dev mailing list