elements of decorator syntax suggestions
Peter Hansen
peter at engcorp.com
Fri Aug 6 13:44:59 EDT 2004
Steven Bethard wrote:
> So in summary
> -> yay keywords!
> -> before def or before colon, and
> -> whatever list notation and indentation floats your boat
Good post, Steven, and I agree with all your own opinions on the
matter as expressed above.
Note one addition item that most of us are glossing over in the
debate for/against the pie (@) syntax. Order of operation.
@ syntax has reversed order from the list-after-def. I think
the order should be readily apparent from the syntax, and I
think the list syntax does provide that benefit over the @ syntax.
I think I'd like a "decorate" keyword (or equivalent), *before*
the definition to avoid the problems with obscuration, and a
mandatory list of some kind that clearly shows the order.
Something like, but not necessarily exactly the same as, this:
from __future__ import decoration
decorate [
foo,
bar,
bletch(spam='baz')
]
def func(): ...
The only problem is that it still has the defect of @ wherein
the decorate doesn't seem to "bind" to the function def very
well, especially if blank lines are allowed etc.
I'm unclear on what I think it best... but then I don't mind
the current approach much at all, where you just stick the
stuff after the entire function block, so who cares about my
opinion? ;-)
-Peter
More information about the Python-list
mailing list