Simon Willison’s Weblog

6 items tagged “decorators”


Better Python Decorators with wrapt (via) Adam Johnson explains the intricacies of decorating a Python function without breaking the ability to correctly introspect it, and dicsusses how Scout use the wrapt library by Graham Dumpleton to implement their instrumentation library. # 2nd July 2020, 9:48 pm


django-boss (via) Management commands are one of the few bits of Django that I still have to look up in the documentation whenever I write them. django-boss offers a smart alternative to regular management commands, based around decorators and taking the containing app as the first argument. # 1st June 2010, 10:02 am


Decorator to limit request rates to individual views. Neat piece of code for public facing web APIs written in Django. Update: some smart criticisms in the comments. # 24th September 2008, 1:13 pm

AOP aspect of JavaScript with Dojo. Fantastic post—concisely explains Aspect Oriented Programming, then shows how Dojo’s dojox.lang.aspect brings AOP to JavaScript, including some really useful built-in aspects for logging, profiling and more. Aspects are like Python decorators on steroids. # 18th May 2008, 10:45 am

Monkeypatching idioms—elegant or ugly? Guido offers a decorator and a metaclass as syntactic sugar for monkeypatching existing Python classes. # 30th January 2008, 12:39 am


Meta-classes Made Easy. Fuzzyman introduces a metaclass factory for applying a decorator to every method of a class. # 17th December 2006, 12:42 am