Categories
Blog

Generators and decorators in Python

Was reading through some old blog posts today and found an interesting talk about Coroutines and Concurrency. The talk is pretty long but presents some nice ideas about how to split a problem up and making it more modular using yielding. It seems like python has extended this a little so that you can actually use generators to consume messages also. What I found particular interesting though in the talk, was when he briefly showed a decorator. Decorators are really powerful and seems to bring about the best of lisps macro extensability to Python without loosing the excellent syntax 🙂 I googled a bit and found the following list of patterns that you can do with decorators.