Decorating functions without losing their signatures

Rotwang sg552 at hotmail.co.uk
Wed Apr 3 22:17:58 EDT 2013


On 04/04/2013 02:18, Michele Simionato wrote:
> On Wednesday, April 3, 2013 3:05:31 AM UTC+2, Rotwang wrote:
>> After thinking about it for a while I've come up with the following
>>
>> abomination
>
> Alas, there is actually no good way to implement this feature in pure
> Python without abominations. Internally the decorator module does
> something similar to what you are doing. However, instead of cooking up
> yourself your custom solution, it is probably better if you stick to
> the decorator module which has been used in production for several
> years and has hundreds of thousands of downloads. I am not claiming
> that it is bug free, but it is stable, bug reports come very rarely and
> it works for all versions of Python from 2.5 to 3.3.

Thanks, I'll check it out. Looking at the link Steven provided, I didn't 
see an easy way to add additional keyword-only arguments to a function's 
signature, though (but then I've yet to figure out how the FunctionMaker 
class works).




More information about the Python-list mailing list