from typing import Dict
from typing import Any
from typing import Optional


def dict_get_and_del(d: Dict[str, Any],
                     key: str,
                     default: Optional[Any] = None) -> Any:
    """
    Get the value of a key from a dictionary, and remove the key.

    :param d:        the dictionary
    :param key:      the key
    :param default:  the default value, if the key isn't present

    :return: The value, with d possibly modified
    """
    if key in d:
        res = d[key]
        del d[key]
        return res

    return default