Skip to content

Comment on Introduction to Python Decorators

Comments

An excellent tutorial/answer about python decorators was posted on stack overflow:

http://stackoverflow.com/questions/739654/understanding-pyth...

I would replace "excellent" with "extremely thorough."

I would recommend the posted link for a first introduction -- it's short, explains decorators as clearly but more approachably, and talks about their application to classes, something the SO answer misses.

Thanks for the link. As a python newbie, the way that helped me best was going through the stack overflow link and then the posted article. From what I understand its also important to understand when the decorator function is executed. Before or after the function it decorates.(I understand its also possible, that it executes both before and after). Is this understanding correct?

xlmOP

Agreed, I read that one as well. What struck me was the link the author drew to LISP macros.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.