parameter passing question

Micah dropthis_fanmail at micah-wedemeyer.net
Tue Sep 21 00:36:36 CEST 2004


Use the variable-arg techniques described in:
http://docs.python.org/ref/function.html

def foo(*args):
    # Do something with arg[0], arg[1], ...

def main():
    f = foo
    args = ["hello", "world"]
    f(*args)

------

Is there a way to do it if I am not the one to define f?  In other words, if
I cannot declare f to be a variable-argument function, is there a way to do
it?

I'm trying to write a function F that takes a function f and a list of
arguments args for f.  I leave it up to the caller of F that they pass the
correct number of arguments.

Thanks for the speedy reply,
Micah





More information about the Python-list mailing list