Decorators: an outsider's perspective

Ben Last ben at benlast.com
Sun Aug 15 04:10:35 EDT 2004


Hans (Hans Nowak (hans at zephyrfalcon.org)) wrote:
>This post wasn't deriding decorators; rather, it explains them,
>and provides some examples of how to use them.  I do question
>their usefulness, but I'm not deriding them, nor the "@" syntax.
Just to be contrary, *this* post isn't questioning the usefulness of
decorators (though I've yet to see a case that really makes me feel they're
a killer feature), but *is* questioning the syntax (not deriding - I don't
do derision!)

The "@" notation feels a little bit Perl-esque to me, in a "let's overload
another symbol" type of way.  It doesn't seem to follow the general
Python-zen model of using explicit words for extra functionality, such as
"staticmethod".  I appreciate it's just syntactic sugar, but one could make
that same case for, say, the $_ variable in Perl.

Given (for the sake of argument), that decorators are useful (and here I'm
admitting that I may well be in ignorance of the finer points of their
requirements), do they *really* require a dedicated extension to the
language?  Surely; those who are aware of the need for decorators will also
tend to be competent to build them using the language features that already
exist, obviating the need for special syntax?  Although I concede the edge
case of experienced developers in another language who come to Python and
want to use such power-user features from day one.

This comment offered in all humility, as a first post :)

Ben

PS: Paul (Morrow): when I read your statement "I'm really not sure that
those 'Zen' items were intended to be absolute guiding principles", I
couldn't help but remember Captain Barbossa in Pirates Of The Caribbean -
"the [Pirate] code's more what you would call guidelines than actual
rules..." :)




More information about the Python-list mailing list