Can you fix up wrapper function argument signatures?

G

Gerard Brunick

Consider:
.... def wrapper(*args, **kwargs):
.... return not func(*args, **kwargs)
.... return wrapper
........ return x > 10
....True

Now g has the argument signature of (*args, **kwargs). Pop-up help in
Python
Scripter(which is great by the way) tells me this, as does
('args', 'kwargs')

Is there anyway to fix this in negate? I assume that I can't just start
changing things in g.func_code since the bytecodes depend on the order
of variables and lots of other stuff that I don't claim to understand.

Please note: From the new functools module, I see that one can set/update
__module__, __name__, __doc__, and __dict__ using the corresponding
attributes
from the wrapped function; however, none these fix up the argument signature
do they? (I'm still running 2.4, so I haven't tried it.)

Thanks,
Gerard
 
D

Diez B. Roggisch

Gerard said:
Consider:

... def wrapper(*args, **kwargs):
... return not func(*args, **kwargs)
... return wrapper
...
... return x > 10
...
True

Now g has the argument signature of (*args, **kwargs). Pop-up help in
Python
Scripter(which is great by the way) tells me this, as does

('args', 'kwargs')

Is there anyway to fix this in negate? I assume that I can't just start
changing things in g.func_code since the bytecodes depend on the order
of variables and lots of other stuff that I don't claim to understand.

Please note: From the new functools module, I see that one can set/update
__module__, __name__, __doc__, and __dict__ using the corresponding
attributes
from the wrapped function; however, none these fix up the argument
signature
do they? (I'm still running 2.4, so I haven't tried it.)

You can use Michele Simionato's decorator-module.

http://www.phyast.pitt.edu/~micheles/python/documentation.html

HTH,

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top