March 8, 2006
3:54 p.m.
Dang, got away from me, anyway, like: def switch(choice, functions = [cf0, cf1, cf2, cf3]) if 0<choice<len(functions): return functions [ choice ] # functions is a list of function objects else: print "Not valid" return variations on that theme, i.e. not a big if, elif, elif, else -- just use choice as an index into a list of functions. Kirby On 3/8/06, kirby urner <kirby.urner@gmail.com> wrote:
Cool, I'm in. Checking out your moodle.
Another way people write switch:
def switch(choice): if 0<choice<len(functions):