A couple of days ago, I asked a question about generating tests for Nose. Jacob Kaplan-Moss (of Django fame) provided a elegant answer that I can understand in retrospect, but would probably not have been able to come up with myself. If you’re interested in Python decorators and generators, check out my summary on the Software Carpentry blog.
This is probably because while many Python programmers use decorators, very few actually seem to know how to write them. Very few Python programmers seem to write functions that return functions for that matter as well.
It’s a powerful paradigm, and kind of a bummer that it isn’t used more often as it really does make many things much more pleasant to write, and test. Framework authors generally come up with solutions involving this stuff first since they’re used to writing decorators for use by other developers.