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

Nick Coghlan ncoghlan at gmail.com
Sat Sep 16 08:21:03 EDT 2017


On 16 September 2017 at 21:22, Serhiy Storchaka <storchaka at gmail.com> 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 eventual topic that I
can't find it with Google.

Anyway, I think the outcome of that particular thread was something like:

1. The most reasonable-sounding enhancement request is the one to
allow subscripts: "@deco_group[deco_id]"
2. If we're going to relax the restrictions at all, it probably makes
sense to just allow arbitrary expressions
3. You can already use arbitrary expressions in practice by defining
"def deco(x): return x", and then writing
"@deco(whatever_expression_you_want)"
4. Nobody was motivated enough to actually implement the change and
then ask Guido if he'd changed his mind on the topic since 2004

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list