The best and most robust technique is to use a dictionary that maps strings to function objects, as described in this article: