parameter passing question

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


Python gurus:

No, this isn't about pass-by-value vs pass-by-reference, this is more along
the lines of functional programming.

Basically, I want to be able to call a function on a list of arguments
without knowing the syntax of the function.  I guess a code example would be
best:

-------
def foo(arg1, arg2):
    # Do something with arg1 and arg2

def main():
    f = foo
    args = ["hello", "world"]
    # Want to call foo("hello", "world") using variable f and list args
--------

So, what I'm trying to do is call f(args[0], args[1]).  However, I want to
be able to do it with any length argument list.  Given any function f and a
list of arguments args, I want to be able to call f(args[0], args[1], ...,
args[n])

Any suggestions?

-- 
=================================
Micah Z. Wedemeyer
Research Scientist I, ELSYS
Georgia Tech Research Institute
Atlanta, GA 30332
678.428.1283
=================================





More information about the Python-list mailing list