[Python-Dev] dict.discard (original) (raw)
Gustavo Niemeyer gustavo at niemeyer.net
Thu Sep 21 16:07:04 CEST 2006
- Previous message: [Python-Dev] dict.discard
- Next message: [Python-Dev] list.discard? (Re: dict.discard)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 http://niemeyer.net
- Previous message: [Python-Dev] dict.discard
- Next message: [Python-Dev] list.discard? (Re: dict.discard)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]