def case(*keys, **kwargs):
    """Decorator: tags an attribute (probably a method) as a case object."""
    keys = list(keys)
    _default = kwargs.pop('default', False)
    _itsname = kwargs.pop('itsname', False)
    _classmethod = kwargs.pop('classmethod', False)
    _staticmethod = kwargs.pop('staticmethod', True)  # default option
    if kwargs:
        raise TypeError(
            'case() got unexpected keyword arguments: %s' %
            ', '.join(sorted(kwargs)))
    def case_decorator(obj):
        if _default:
            keys.append(_DEF_CASE_KEY)
        if _itsname:
            keys.append(obj.__name__)
        obj._switch_case_keys = keys
        if _classmethod:
            return classmethod(obj)
        elif _staticmethod:
            return staticmethod(obj)
        else:
            return obj
    return case_decorator
Decorator: tags an attribute (probably a method) as a case object.
recipes/Python/577864_Fast_elegant_switchcaselike/recipe-577864.py