Contribute Media
A thank you to everyone who makes this possible: Read More

Write more decorators (and fewer classes)


In the wake of famous talk “Stop Writing Classes” by Jack Diederich (, I’d like to present a pattern that can be used to design clean and pythonic interfaces for programmers based on replacing single-method classes with decorated functions.

This pattern is already used by some famous frameworks and libraries, like Pyramid (, but I believe it isn’t that well-known to many (even experienced) Python developers and is not as widely used as it deserves.

I’ll show how this pattern can be employed to improve a programming interface which is used by an internal log processing framework at Yelp. This will demonstrate how a more functional approach, leveraging the power of Python decorators, can lead to simpler, more beautiful and easier to understand code.

However, this talk doesn’t suggest giving up classes altogether, but making use of them only when they are truly useful. In fact, the use-case I’m going to analyze will combine classes, functions, and decorators to make the best out of these tools.

Given that the presentation is going to be very code-oriented, the talk is intended for an audience of developers who are already familiar with most Python constructs, including decorators, even though the concept will be briefly introduced at the beginning of the talk. But, if you are one of these people, I promise you that the code will speak for itself.


Improve this page