def dict_pop_or ( d , key , default = None ) : val = default with suppress ( KeyError ) : val = d . pop ( key ) return val
python 3 dict get with defaultvalue
Try popping a key from a dict . Instead of raising KeyError just return the default value .
def dict_pop_or(d, key, default=None):
    """ Try popping a key from a dict.
        Instead of raising KeyError, just return the default value.
    """
    val = default
    with suppress(KeyError):
        val = d.pop(key)
    return val