Wednesday, September 17, 2008

Still can't figure out decorators

After a couple months (roughly) of Python programming, I'm very happy with how far I've come and what I'm able to accomplish. When all this started my biggest struggle was the basic object-oriented programming mindset. After further study and a good bit of trial and error, though, I feel I've got a pretty good handle on it. I'm not a whiz by any stretch, but I'm a lot more comfortable with it now than I was when this all began.

That leads me to the next programming concept I'd like to grok: decorators.

I just stumbled across a blog post in which the author claims that Python's decorators are "radically simple." I'm sorry, but I've read a good number of explanations behind decorators -- including the Wikipedia article on the subject, which includes a pseudo-example in Python -- and this "radically simple" outline (i.e. the slides that Mr. Diederich used in his PyCon UK talk) hasn't made the concept any clearer for me.

Does anyone know where I can find a truly clear description of Python decorators? Perhaps this is something that could be more easily understood if I had a solid computer science background instead of an animator-who-fell-in-love-with-programming-on-the-side background.


1 comment:

turumdarak said...

You might look at the following:

I personally don't know Python, but the "decorator" seems fairly simple. It allows you to tag certain attributes onto the function you are about to declare, instead of modifying the function after the declaration.