[Tutor] Decision matrix

alan.gauld@bt.com alan.gauld@bt.com
Wed Feb 12 18:15:02 2003


> each unique combination of letters 
> should result in a different function being called, like so:

unique string corresponds to value.
Sounds like the definition of a dictionary to me...

Functions = { "r":    function1,
              "rd":   function2,
etc...
               "s":   function6
            }

Instead of

   if seq == "R": function1()
   elif seq == "rd": function2()
etc...

do

    Functions[seq]()

> What would be the most eloquent way to 
> code this sort of decision matrix in Python?

Does that work for you?

Alan G