S
Steven Bethard
I mentioned in a previous post that I'd much prefer some sort of
keyword as a decorator indication than a character like @ (or the
recently suggested |). A promising note on python-dev:
http://mail.python.org/pipermail/python-dev/2004-August/047001.html
I was just going to let this go because I thought it had been shut
down, but as it seems to have been reopened, I'd love to see something
like:
with classmethod
with returns(int)
def func(*args, **kwds):
return 1
Or if you don't like so many lines:
with [classmethod, returns(int)]
def func(*args, **kwds):
return 1
Or perhaps, if you like to see the def by itself:
def func(*args, **kwds) with [classmethod, returns(int)]:
return 1
Really, I'd be much happier with any of these than any of the solely
symbol-based versions. Neither [] alone after a function def or '@'
before one reads clearly to me as an indicator of decoratorhood.
I've always liked that Python tries to be human-readable (e.g. "for x
in lst" reads almost like English). If at all possible, I'd like
decorators to be the same way. In fact, while I've only used 'with'
above (because it was non-'as' keyword suggestion in the wiki), I'd be
just as happy (maybe happier) with 'decorate' or 'deco' or something
along those lines that would read even easier.
Steve
keyword as a decorator indication than a character like @ (or the
recently suggested |). A promising note on python-dev:
http://mail.python.org/pipermail/python-dev/2004-August/047001.html
Perhaps this could be addressed by requiring "from __future__ import
decorators", for one release, just like was done for "yield". I
expect that this would be acceptable to the ObjC folks, too. It
wouldn't be my favorite, but I won't rule it out just because of the
new keyword (and yes, this is a softening of my position on new
keywords).
--Guido van Rossum (home page: http://www.python.org/~guido/)
I was just going to let this go because I thought it had been shut
down, but as it seems to have been reopened, I'd love to see something
like:
with classmethod
with returns(int)
def func(*args, **kwds):
return 1
Or if you don't like so many lines:
with [classmethod, returns(int)]
def func(*args, **kwds):
return 1
Or perhaps, if you like to see the def by itself:
def func(*args, **kwds) with [classmethod, returns(int)]:
return 1
Really, I'd be much happier with any of these than any of the solely
symbol-based versions. Neither [] alone after a function def or '@'
before one reads clearly to me as an indicator of decoratorhood.
I've always liked that Python tries to be human-readable (e.g. "for x
in lst" reads almost like English). If at all possible, I'd like
decorators to be the same way. In fact, while I've only used 'with'
above (because it was non-'as' keyword suggestion in the wiki), I'd be
just as happy (maybe happier) with 'decorate' or 'deco' or something
along those lines that would read even easier.
Steve