Re:Hidden features of Python
by shadytrees on Monday September 22, 2008 @02:46PM
(#311474)
Agreed. The decorator idea didn't just come out of nowhere: It merely codified a convention that appeared in a lot of code where `function` would be defined and then you'd see `function = decorate(function)` afterward. (This is, for example, arguably the core idea of WSGI.)
[ Parent
| on HN ]
Right. So ... why bother with adding a feature to the language when the language as it already exists can do it in one easily-comprehended line of six tokens? I'm sure you like the shorter syntax better. But I didn't know it, despite years of experience with scripting languages (and even this paradigm) that should have informed me about what that code means.
But it didn't, for the simple reason that it looked funny because I haven't been keeping up with Python. I'll say it one last time: this idea, that the language should cater to its experts by adding features wherever possible, is what has killed C++ as a hacker's language. Python is walking blindly down the same path.
"So ... why bother with adding a feature to the language when the language as it already exists can do it in one easily-comprehended line of six tokens?"
The decorator syntax is easier to read. It's at the top of the function where the arguments list and docstring are. Yes, there are tradeoffs when introducing new syntax, but decorators are definitely worth it.