How do I create an array of functions?

Paul Rubin http
Mon Feb 19 03:23:51 EST 2007


"Steven W. Orr" <steveo at syslang.net> writes:
> I have a table of integers and each time I look up a value from the
> table I want to call a function using the table entry as an index into
> an array whose values are the different functions.  I haven't seen
> anything on how to do this in python.

func_array = [f1, f2, f3]    # array of functions
index = table_lookup()
func_array[index](x,y,z)     # select a function and call it



More information about the Python-list mailing list