remaining decorator syntax options

Steven Bethard steven.bethard at gmail.com
Wed Aug 11 17:17:57 CEST 2004


Shalabh Chaturvedi <shalabh at cafepy.com> wrote in message news:<mailman.1472.1092171803.5135.python-list at python.org>...
> @staticmethod
> @foo.moredecoration(a="hello",b="world")
> @foo.bar.baz()
> def myfunc():
> 
> vs.
> 
> using [staticmethod ,foo.moredecoration(a="hello",b="world"), foo.bar.baz()]
> def myfunc():
> 
> (I find the first version clearer.)

Yup.  Though I think most people would write the second option
something like:

using [staticmethod,
       foo.moredecoration(a="hello",b="world"),
       foo.bar.baz()]
def myfunc():

(with, of course, a hundred different tabulation options there, but
you get the idea).  My point was that with the keyword, you save a lot
of keystrokes using the list if you have a large number of decorators,
but with a single symbol, of course, using a list only adds
keystrokes.  You make some good points though, and I would be just as
happy with:

using staticmethod
using foo.moredecoration(a="hello",b="world")
using foo.bar.baz()
def myfunc():

> Btw, I think your summary of the current state is good. However I feel a 
> new keyword has been pretty much ruled out as well.

Can you refer me to some pages that made you feel this way?  GvR said
that he "won't rule it out just because of the new keyword":

http://mail.python.org/pipermail/python-dev/2004-August/047001.html

I also haven't seen any arguments against keywords that said anything
but basically "introducing a new keyword might break existing code". 
Not that this isn't a valid argument, but as Python has gone through a
similar process recently for 'yield', I'd feel more like keywords were
ruled out if I heard some other arguments.

Steve



More information about the Python-list mailing list