Decorator syntax

Paul McGuire ptmcg at
Fri Aug 6 00:32:16 CEST 2004

"Andrew Bennetts" <andrew-pythonlist at> wrote in message
news:mailman.1182.1091694251.5135.python-list at
> On Thu, Aug 05, 2004 at 04:25:13AM +0000, Paul McGuire wrote:
> [...]
> >
> > I fear that $, ^ and ~ are just around the corner.
> No need to fear: ^ and ~ are already there.
> >>> ~1
> -2
> >>> 1^2
> 3
> -Andrew.

Ooops, duh!  I guess I meant "$ and ?".

As this discussion wears on (and on...), there are several comments to the
effect of "let's save @ for something really important, and not waste it on
decorators."  Personally, I've enjoyed the clean look of Python source that
isn't splattered with special @'s and $'s.  I *don't* want to save @ for
something important, I'd prefer to see it kept out of the syntax altogether,
along with $.  (Oddly, I don't find ? near as ugly, but I wouldn't suggest
it as an alternative to @ as a decorator-introducer.)

I don't see this as merely a personal style choice either, as in "if you
don't like @'s, don't use @'s" - it seems to me that the emergence of a
decorator syntax means that I'll at some point have to use them to replace
the deprecated staticmethod and classmethod keywords.

@ and $ evoke the old days of job control commands and all-caps coding in
Cobol and FORTRAN - anyone care for code like:


It seems to me that historically Python has eschewed using special
characters in other cases.  For instance, rather than mark instance methods
of a class with some magic character (such as '>', say), they contain an
explicit 'self' argument (whether this is good or ill is secondary - it IS
what Python does).  There is no special use of '^' as a shortcut for
'return' (as in Smalltalk's ubiquitous "^self") - one writes "return self".

Please reconsider the "def f() [classmethod]:" construct.  Instead of
invoking a special punctuation character, it uses context and placement,
with familiar old []'s, to infuse the declaration of a function with special
characteristics.  If this causes def lines to run longer than one line,
perhaps the same rule that allows an unmatched "(" to carry over multiple
lines without requiring "\" continuation markers could be used for unmatched
"["s, as in:

def f() [ staticmethod,
    returns('d') ]:

"If I'd wanted mucilage, I'dve ordered mucilage." - Humphrey Bogart, "All
Through the Night"
If I'd wanted to write in Java, I'dve written in Java.

Keep Python Beautiful.
-- Paul

More information about the Python-list mailing list