@decorator syntax is sugar, but for what exactly? (decorator libraries).

Roy Smith roy at panix.com
Sun Aug 8 17:24:32 CEST 2004

In article <mailman.1361.1091977078.5135.python-list at python.org>,
 Andrew Durdin <adurdin at gmail.com> wrote:

> On Sun, 08 Aug 2004 10:46:38 -0400, Roy Smith <roy at panix.com> wrote:
> > In article <mailman.1360.1091975279.5135.python-list at python.org>,
> > 
> > Wow, I'm glad I asked.  That answer is quite surprising, and somewhat
> > disconcerting.  Lot's of special cases going on here, which is bad.
> Well, I think I agree with the principle of limiting the expressions
> to dotted names. Some of the possibilities if you allow arbitrary
> expressions are pretty hairy:
> """
> Things someone might want to do, ordered roughly from most reasonable
> to least reasonable ;)
> @foo().bar()
> @foo or bar
> @mydecorators['foo']
> @lambda f: foo(f) or bar(f)
> """
> (from http://mail.python.org/pipermail/python-dev/2004-August/046673.html)

You can always do lots of hairy things all over the place.  Shall we 
limit functions to no more than 4 arguments?  Assignment statements to 
no more than 5 operators?  Function calls to nesting no more than 3 
deep?  I'm not in favor of hair, but the way to contain it is with good 
style and practice, not with arbitrary constraints in the grammar.

The most simple thing is the most general thing.  The thing after the @ 
gets called, therefore it must be a callable object.  I don't see any 
need to specify anything further.

It's not good style to crassly split infinitives either, but it sure 
would be annoying if my news client prevented me from doing it.

More information about the Python-list mailing list