[Python-Dev] Call for defense of @decorators

Skip Montanaro skip at pobox.com
Fri Aug 6 04:57:47 CEST 2004


    Anthony> From being a -0 (when Guido first mentioned it) to a +0 (at the
    Anthony> time of checkin) I'm now +1 on this form of decorator.

It's still not my first choice.  As others have observed, most functions
have no more than three parameters and it should be rare for a function to
have more than two decorators, so in the common case the list-after-def
works (decorators are prominent - on the def line), but don't obscure the
beginning of the definition ("def", function name, parameter list).

    Anthony> (It's different in that way to "print >>", which I still hate
    Anthony> <wink>)

Odd, I've always liked it.  I use it heavily for debugging.  The ">>" is
easy to grep for when I want to rip 'em out, and I can combine the
convenience of the print statement with redirection to stderr.

    Anthony> "The @ sign is used in Perl."
    Anthony> And?

I think the point there is that Perl has this history of using prefix
punctuation ($, @, %) to modify the meaning of the identifier that follows,
and more generally using punctuation in all sorts of non-mnemonic ways.  To
a certain degree @-decorators have that same feel.

Skip


More information about the Python-Dev mailing list