def _extract_from_dict(dictionary, key, default=None):
    """Extract a given key from a dictionary.  If the key doesn't exist
       and a default parameter has been set, return that.
    """

    try:
        value = dictionary[key]
        del dictionary[key]
    except KeyError:
        value = default

    return value