[Tutor] Decision matrix

Poor Yorick gp@pooryorick.com
Wed Feb 12 11:29:16 2003


The following question will expose the fact that I am mathematically 
challenged, but here goes...

I have a function which takes a string as a paramater.  Each letter in 
the string represents a switch, and each unique combination of letters 
should result in a different function being called, like so:

STRING        FUNCTION

r                    function1
rd                  function2
rds                 function3
d                    function4
ds                  function5
s                    function6

I've toyed with a series of if statements and considered constructing a 
bitwise variable with which to index a dictionary of functions, and am 
now looking for suggestions.  What would be the most eloquent way to 
code this sort of decision matrix in Python?

Poor Yorick
gp@pooryorick.com