Re: Decorating functions without losing their signatures

2013-04-03 Thread Rotwang
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. Interna

Re: Decorating functions without losing their signatures

2013-04-03 Thread Rotwang
On 03/04/2013 05:15, Steven D'Aprano wrote: On Wed, 03 Apr 2013 02:05:31 +0100, Rotwang wrote: Hi all, Here's a Python problem I've come up against and my crappy solution. Hopefully someone here can suggest something better. I want to decorate a bunch of functions with different signatures; [

Re: Decorating functions without losing their signatures

2013-04-03 Thread Rotwang
On 03/04/2013 02:05, Rotwang wrote: [...] After thinking about it for a while I've come up with the following abomination: import inspect def sigwrapper(sig): if not isinstance(sig, inspect.Signature): sig = inspect.signature(sig) def wrapper(f): ps = 'args = []\n\t\t' ks

Re: Decorating functions without losing their signatures

2013-04-03 Thread Michele Simionato
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 s

Re: Decorating functions without losing their signatures

2013-04-02 Thread Jan Riechers
On 03.04.2013 04:05, Rotwang wrote: Hi all, Here's a Python problem I've come up against and my crappy solution. Hopefully someone here can suggest something better. I want to decorate a bunch of functions with different signatures; for example, I might want to add some keyword-only arguments to

Re: Decorating functions without losing their signatures

2013-04-02 Thread Steven D'Aprano
On Wed, 03 Apr 2013 02:05:31 +0100, Rotwang wrote: > Hi all, > > Here's a Python problem I've come up against and my crappy solution. > Hopefully someone here can suggest something better. I want to decorate > a bunch of functions with different signatures; [...] > After thinking about it for a w

Decorating functions without losing their signatures

2013-04-02 Thread Rotwang
Hi all, Here's a Python problem I've come up against and my crappy solution. Hopefully someone here can suggest something better. I want to decorate a bunch of functions with different signatures; for example, I might want to add some keyword-only arguments to all functions that return instan