def _toggle(mapping, key, value):
    """If *key* is set in *mapping*, delete its value.  Otherwise, set
    *key* to *value*."""
    if key in mapping:
        del mapping[key]
    else:
        mapping[key] = value
