Emanuel Barry added the comment:

TL;DR - Use case is dynamic decorators. Not all of the syntax would make sense, 
see below.

The main benefit of this feature would be for dynamic decorators (as was 
evidenced from others in this issue). In a project I contribute to, we use 
dynamic decorators to set a function as being a command, and we use the object 
(a wrapper around the function) directly, so we need a bit more boilerplate 
around the place.

Ultimately, we would definitely use such a feature (just the '@spam().eggs()' 
part; we'd have no use for the other ones) , but we probably won't notice its 
absence either; we've worked around it for years, after all.

As far as readability goes, I think allowing only the '@spam().eggs()' version 
would actually improve readability quite a bit, by reducing the need to 
separate the decorator assignment in two (or more) parts. I can see the desire 
to have a '@spam[eggs]' kind of syntax though, again for the dynamic decorators 
case.

I see no reason to allow creating lambdas or conditional expressions inside 
decorators expressions. If anything, that'll encourage anti-patterns, whereas 
e.g. '@spam(value=eggs)' would be more readable, and would let the decorator 
decide what it wants to do with the value.

And if your decorator can be expressed as a lambda, why don't you put that 
in/below the function? Surely it's less work than writing the lambda everytime 
;)

----------
nosy: +ebarry
versions: +Python 3.6 -Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19660>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to