J2 proposal: keyword
David Pokorny
davebrok at soda.csua.berkeley.edu
Mon Aug 23 04:36:31 EDT 2004
"Anthony Baxter" <anthonybaxter at gmail.com> wrote in message
news:mailman.2175.1093233838.5135.python-list at python.org...
> On Mon, 23 Aug 2004 00:23:32 +0100 (BST), Michael Sparks
> <zathras at thwackety.com> wrote:
> > I discovered this after replacing "decorate" with "using" and
> > rerunning the test suite... Incidentally the syntax also allows
> > code like this:
> >
> > using:
> > staticmethod synchronised memoise deprecated
> > def: foo(bar):
> > "This function foos bars all day long"
> > pass
>
> The pie-decorator syntax was modified shortly after a2 to require
> one decorator per line. I think for readability's sake, this was a good
> call, and would urge you to do this in any new syntax.
There must be some cognitive-visual thingamajig going on here because I find
using:
staticmethod synchronized memoize
def bar(foo):
"upends the established order of metasyntactic keywords"
pass
much more readable than
@staticmethod synchronized memoize
def bar(foo):
"upends the established order of metasyntactic keywords"
pass
[I think it has something to do with the traffic jam at the left margin.]
Aesthetically, putting multiple decorators per line allows the eye to scan
in all of them in one fell swoop. In other words, the one-liner
using:
staticmethod synchronized memoize
def bar(foo):
"To colon or not to colon? Def is the question."
pass
is easy on the eye while
using:
staticmethod
synchronized
memoize
def bar(foo):
"english teachers will call you on putting two colons in one sentence"
pass
looks like the SUV of decorators ;)
David
More information about the Python-list
mailing list