def test_dict_based_with_try_except():
        "ordinary-dict-based switch + try/except-based default case support"
        switch = DictBasedSwitch.switch
        default_case = DictBasedSwitch.get_default_case()
        _error = KeyError
        x = ''
        for key in case_keys:
            try:
                x = switch[key](x[:10])
            except _error:
                x = default_case(x[:10])
ordinary-dict-based switch + try/except-based default case support
recipes/Python/577864_Fast_elegant_switchcaselike/recipe-577864.py