[portland] introspecting method signatures
hallettj at gmail.com
Wed Oct 22 23:09:17 CEST 2008
I found this link with code for aliasing methods. You can probably alias the
original method, then override the original method name with a new method,
and call the aliased method from the new method.
I haven't tried the code though; so I can't guarantee that it works.
On Oct 22, 2008 1:45 PM, "Jeff Schwaber" <freyley at gmail.com> wrote:
I'm trying to find a way to get method signatures at runtime, or pass
signatures straight through to an inside function. I'm basically
trying to redefine functions to do what they currently do but do
something else first. My current idea, stymied by signatures, is to
create closures wrapping the functions.
So something like this:
def foo(a, b):
def bar(b = None):
funclist = [foo, bar]
closurelist = 
for func in funclist:
def closure(): # this should have the arguments for the func
# do something
func() # so I can pass them in here
The closest I've found is func.func_code.co_varnames, which is a list
of variables in the signature, but it doesn't have default arguments
or mark any which are * or **. Anybody know the right way to do this,
or am I barking up the wrong tree? The # do something is what I'm
Portland mailing list
Portland at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Portland