[Python-Dev] def ... decorate (original) (raw)
Raymond Hettinger python at rcn.com
Fri Aug 13 20:11:06 CEST 2004
- Previous message: [Python-Dev] def ... decorate
- Next message: [Python-Dev] def ... decorate
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I've kept my nose out of the decorator discussion, but I thought I would give my opinion on this one...
> On Fri, 13 Aug 2004, Skip Montanaro wrote: > > >with > > > > def pstatementexpr: > > staticmethod > > grammarrule('statement : expression') > > version("Added in 2.4") > > deprecatedmethod > > type(None) > > decorate (self, p): > > """docstring here""" > > print p[1] > > Bingo! Oh god no. > Just replace decorate with "from" and the nice syntax is found: > > def f: > staticmethod > grammarrule('statement : expression') > version("Added in 2.4") > deprecatedmethod > type(None) > from self, p: > """docstring here""" > print p[1] Gah, the horror.
I think we should take maximum advantage of prior art. Other languages have proven the efficacy of backwards spellings. Likewise, the reST module has proven the utility of ASCII markup.
dothemcitats::
elurrammarg ``statement : expression''::
dohtemdetacerped::
``````````````````
def f(arg):
. . .
Advantages:
Won't delude people into thinking they can understand a python program just by reading it.
Highly adaptable to electronic parsing while discouraging the adverse trend towards human readability.
Accomplishes the life saving core goal of moving decorators up a few lines while only incurring the minor cost of complicating the snot out of the language.
Unlikely to be confused with any existing python constructs.
Takes less effort to implement, document, and test than to read all of the decorator syntax emails to date.
Alternative:
A further application of prior art would be to hypergeneralize the solution to this problem and design a solution using XML. This takes maximum advantage of existing tools while providing a framework for all potential future proposals to add a second or third way to accomplish things we can already do now.
citsacras-ly yours,
Raymond
- Previous message: [Python-Dev] def ... decorate
- Next message: [Python-Dev] def ... decorate
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]