Python 2.4.4, Solaris 10

I have a file of functions. Based on what is read in a data file,
different functions in the file of functions will need to be called. I
have been trying to make the following approach work, so far
unsuccessfully as, in general, each function may have a different
number of arguments that might have to be passed to it.

def func1(x1, x2, x3):
    pass

def func2(y1, y2):
    pass

def func3(z):
    pass

call_fcn = {'a': func1, 'b': func2, 'c': func3}

call_fcn[key_letter](???)

How can I successfully pass the needed arguments needed for each
possible function with this approach? I naively tried to do something
like:

pass_args = {'a': (x1, x2, x3), 'b': (y1, y2), 'c': (z)}
call_fcn[key_letter](key_letter)

But ran into the syntax error that I was giving one argument when
(possibly) multiple arguments are expected.

Is what I am trying to do a viable approach that can be made to work?
Otherwise, I will brute-force my way through with if-elif-else
statements.

Thanks!

-- 
boB
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to