[Python-ideas] Decorations
Scott David Daniels
Scott.Daniels at Acm.Org
Mon Jul 13 20:55:49 CEST 2009
Andrey Fedorov (should have written so as to avoid top-posting):
> Daniel Stutzbach wrote:
>
>> Andrey Fedorov wrote:
>>
>>> ... It seems to me everything but line 5 "assert..." is cruft...
>>> it makes sense to call that line the "decoration"....
>>
>> You might be interested in the decorator module, which similarly
>> tries toreduce the amount of boiler-plate code needed to build
>> a decorator:
>> http://pypi.python.org/pypi/decorator
>> (though it does not address exactly the same use case that you
>> are addressing)
>
> Thanks for the pointer. One thing the decorator library doesn't solve is
> abstracting the boiler of decorators that take parameters (and making it
> simple to switch between "parametrized" decorators, "naked" decorators, and
> "mixed" decorators). Although it's certainly worth giving some thought to
> and re-considering some of my internals.
Also consider using in functools.partial to convert your "parametrized"
(or "mixed" decorators, I don't quite get your distinction) to "naked"
decorators.
--Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-ideas
mailing list