<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: decorators</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/decorators.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2020-07-02T21:48:39+00:00</updated><author><name>Simon Willison</name></author><entry><title>Better Python Decorators with wrapt</title><link href="https://simonwillison.net/2020/Jul/2/better-python-decorators-wrapt/#atom-tag" rel="alternate"/><published>2020-07-02T21:48:39+00:00</published><updated>2020-07-02T21:48:39+00:00</updated><id>https://simonwillison.net/2020/Jul/2/better-python-decorators-wrapt/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://adamj.eu/tech/2020/07/02/better-python-decorators-with-wrapt/"&gt;Better Python Decorators with wrapt&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Adam Johnson explains the intricacies of decorating a Python function without breaking the ability to correctly introspect it, and discusses how Scout use the &lt;a href="https://pypi.org/project/wrapt/"&gt;wrapt&lt;/a&gt; library by Graham Dumpleton to implement their instrumentation library.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/AdamChainz/status/1278804597121986560"&gt;@AdamChainz&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/decorators"&gt;decorators&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/adam-johnson"&gt;adam-johnson&lt;/a&gt;&lt;/p&gt;



</summary><category term="decorators"/><category term="python"/><category term="adam-johnson"/></entry><entry><title>django-boss</title><link href="https://simonwillison.net/2010/Jun/1/djangoboss/#atom-tag" rel="alternate"/><published>2010-06-01T10:02:00+00:00</published><updated>2010-06-01T10:02:00+00:00</updated><id>https://simonwillison.net/2010/Jun/1/djangoboss/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://bitbucket.org/zacharyvoase/django-boss/src"&gt;django-boss&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
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.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="http://blog.zacharyvoase.com/2010/02/03/django-project-conventions/"&gt;Django project conventions, revisited&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/decorators"&gt;decorators&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/zachary-voase"&gt;zachary-voase&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/recovered"&gt;recovered&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/djangoboss"&gt;djangoboss&lt;/a&gt;&lt;/p&gt;



</summary><category term="decorators"/><category term="django"/><category term="python"/><category term="zachary-voase"/><category term="recovered"/><category term="djangoboss"/></entry><entry><title>Decorator to limit request rates to individual views</title><link href="https://simonwillison.net/2008/Sep/24/django/#atom-tag" rel="alternate"/><published>2008-09-24T13:13:29+00:00</published><updated>2008-09-24T13:13:29+00:00</updated><id>https://simonwillison.net/2008/Sep/24/django/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.djangosnippets.org/snippets/1083/"&gt;Decorator to limit request rates to individual views&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Neat piece of code for public facing web APIs written in Django. Update: some smart criticisms in the comments.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/apis"&gt;apis&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/decorators"&gt;decorators&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/rate-limiting"&gt;rate-limiting&lt;/a&gt;&lt;/p&gt;



</summary><category term="apis"/><category term="decorators"/><category term="django"/><category term="python"/><category term="rate-limiting"/></entry><entry><title>AOP aspect of JavaScript with Dojo</title><link href="https://simonwillison.net/2008/May/18/eugenes/#atom-tag" rel="alternate"/><published>2008-05-18T10:45:41+00:00</published><updated>2008-05-18T10:45:41+00:00</updated><id>https://simonwillison.net/2008/May/18/eugenes/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://lazutkin.com/blog/2008/may/18/aop-aspect-javascript-dojo/"&gt;AOP aspect of JavaScript with Dojo&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
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.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/aop"&gt;aop&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/aspects"&gt;aspects&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/decorators"&gt;decorators&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/dojo"&gt;dojo&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/dojox"&gt;dojox&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/eugenelazutkin"&gt;eugenelazutkin&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;&lt;/p&gt;



</summary><category term="aop"/><category term="aspects"/><category term="decorators"/><category term="dojo"/><category term="dojox"/><category term="eugenelazutkin"/><category term="javascript"/><category term="python"/></entry><entry><title>Monkeypatching idioms - elegant or ugly?</title><link href="https://simonwillison.net/2008/Jan/30/monkeypatching/#atom-tag" rel="alternate"/><published>2008-01-30T00:39:36+00:00</published><updated>2008-01-30T00:39:36+00:00</updated><id>https://simonwillison.net/2008/Jan/30/monkeypatching/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://mail.python.org/pipermail/python-dev/2008-January/076194.html"&gt;Monkeypatching idioms - elegant or ugly?&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Guido offers a decorator and a metaclass as syntactic sugar for monkeypatching existing Python classes.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/decorators"&gt;decorators&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/guido-van-rossum"&gt;guido-van-rossum&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/idioms"&gt;idioms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/metaclasses"&gt;metaclasses&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/monkeypatching"&gt;monkeypatching&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;&lt;/p&gt;



</summary><category term="decorators"/><category term="guido-van-rossum"/><category term="idioms"/><category term="metaclasses"/><category term="monkeypatching"/><category term="python"/></entry><entry><title>Meta-classes Made Easy</title><link href="https://simonwillison.net/2006/Dec/17/metaclasses/#atom-tag" rel="alternate"/><published>2006-12-17T00:42:09+00:00</published><updated>2006-12-17T00:42:09+00:00</updated><id>https://simonwillison.net/2006/Dec/17/metaclasses/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://www.voidspace.org.uk/python/articles/metaclasses.shtml"&gt;Meta-classes Made Easy&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Fuzzyman introduces a metaclass factory for applying a decorator to every method of a class.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/decorators"&gt;decorators&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/fuzzyman"&gt;fuzzyman&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/metaclasses"&gt;metaclasses&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;&lt;/p&gt;



</summary><category term="decorators"/><category term="fuzzyman"/><category term="metaclasses"/><category term="python"/></entry></feed>