News for hackers. Stuff that matters.
Re:Introduction to Python Decorators by Goladus on Wednesday September 21, 2011 @12:43PM (#3022690)
The only thing I'd like to see more of with respect to decorators is discussion of real benefits. The concept is fairly simple it's the technique and resulting code organization that is interesting. Much like Lisp macros, it's important to know when not to use them and none of the tutorials I've seen really address that.
Re:Introduction to Python Decorators by tripzilch on Monday September 26, 2011 @08:29PM (#3041307)
a good example, when working with the Jinja2 templating language, when you want to declare your own modifier, a function that's called within the templating language like {bit of text|awesomify}, you'd just need to write a function with a decorator on it, like

    @jinja2_modifier
    def awesomify(s):
        return "%s is awesome" % s
(except it wasn't "jinja2_modifier", look it up in the docs)