[Python-Dev] dict.discard

Gustavo Niemeyer gustavo at niemeyer.net
Thu Sep 21 16:07:04 CEST 2006

> Would the argument be the key, or the pair?  I'd guess the key.

Right, the key.

> If so, there's the 2-arg flavor of dict.pop():
>   >>> d = {}
>   >>> d.pop("key", None)
> It's not terribly obvious, but does the job without enlarging
> the dict API.

Yeah, this looks good.  I don't think I've ever used it like this.

Gustavo Niemeyer

More information about the Python-Dev mailing list