'Works like :meth:`list.pop` if no arguments or an index argument are
supplied; otherwise works like :meth:`dict.pop`.'

def pop(self, *args):

    if (len(args) > 2):
        raise TypeError('Header.pop    expected    at    most    2    arguments,    got    {}'.format(len(args)))
    if (len(args) == 0):
        key = (-1)
    else:
        key = args[0]
    try:
        value = self[key]
    except (KeyError, IndexError):
        if (len(args) == 2):
            return args[1]
        raise
    del self[key]
    return value
