djangosnippets.org: Latest snippets tagged with 'metadecorator'https://djangosnippets.org/tags/metadecorator/2011-11-30T12:22:39.349406-06:00decorator for decorators with optional args
2011-11-30T12:22:39.349406-06:00homunqhttps://djangosnippets.org/snippets/2616/<p>Have you ever wanted a decorator that you could apply either straight-out:</p>
<p>@mydec
def myfun(...):
...</p>
<p>or with special arguments:</p>
<p>@mydec(special=foo)
def myfun(...):
...</p>
<p>? Well, decorate it with this metadecorator, and voila.</p>
<p>(I had this idea independently, but it's been done before as decorator_withargs: http://osdir.com/ml/python.ideas/2008-01/msg00048.html. My version is actually …</p>
Freely redistributable