I want a dictionary where keys are regular expressions: d = {'a.*': some_value1, 'b.*': some_value2} d['apple'] I want 'apple' to be matched against the regular expression keys. If there is a complete match with a key/regular-expression then the corresponding value should be returned. 'apple' matches with the regular expression 'a.*' completely, so some_value1 returns. Assume the regular expression keys do not conflict (i.e. two keys should not both match the same string exactly). I'll manually handle that. Continue reading...