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

2017-09-19 Thread Joao S. O. Bueno
I myself found out abotu this restriction once I clashesd into it- soit was one time the restriction bit me back. But I can't remember if that was for intended production code or for toying around either. Anyway, a simple "nop" function can allow for any arbitrary expression to be used as

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

2017-09-18 Thread Éric Araujo
Hello, Le 2017-09-16 à 07:22, Serhiy Storchaka a écrit : > 16.09.17 12:39, Larry Hastings пише: >> So why don't decorators allow arbitrary expressions?  [...] > > Actually I remember somebody raised this question a year or two ago,> but > don't remember details. The discussion I remember

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

2017-09-16 Thread Guido van Rossum
It was and is all very intentional. I don't want to encourage line noise, which the at-sign already resembles. But namespacing and some form of parametrization (i.e. calls) are essential. So that's what we got. On Sep 16, 2017 11:30 AM, "Skip Montanaro" wrote: > >

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

2017-09-16 Thread Skip Montanaro
> Indeed, I can’t remember a single time where I’ve needed that, let alone actually realized the restriction existed. Likewise. I suspect the use of a function sort of just fell out from the pre-decorator usage. Things like staticmethod()

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

2017-09-16 Thread David Mertz
I always realized the restriction was there, and once in a while mention it in teaching. But I've NEVER had an actual desire to use anything other that a simple decorator or a "decorator factory" (which I realize is a decorator in the grammar, but it's worth teaching how to parameterize custom

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

2017-09-16 Thread Barry Warsaw
On Sep 16, 2017, at 02:39, Larry Hastings wrote: > 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. Indeed,

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

2017-09-16 Thread Nick Coghlan
On 16 September 2017 at 21:22, Serhiy Storchaka wrote: > Actually I remember somebody raised this question a year or two ago, but > don't remember details. Aye, I remember that as well, but apparently the thread title for the discussion was sufficiently unrelated to the

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

2017-09-16 Thread Serhiy Storchaka
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

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

2017-09-16 Thread Larry Hastings
The syntax for decorators in the grammar is quite specific: decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE Decorators can be either a dotted name, or a dotted name followed by arguments. This disallows: @mapping['async'] # looking something up in a mapping @func(1, 2,