Re: [Python-Dev] dict.discard

2006-09-21 Thread Gustavo Niemeyer
> 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

Re: [Python-Dev] dict.discard

2006-09-21 Thread Fred L. Drake, Jr.
On Thursday 21 September 2006 09:42, Gustavo Niemeyer wrote: > After trying to use it a few times with no success :-), I'd like > > to include a new method, dict.discard, mirroring set.discard: > >>> print set.discard.__doc__ > > Remove an element from a set if it is a member. > > If

[Python-Dev] dict.discard

2006-09-21 Thread Gustavo Niemeyer
Hey guys, After trying to use it a few times with no success :-), I'd like to include a new method, dict.discard, mirroring set.discard: >>> print set.discard.__doc__ Remove an element from a set if it is a member. If the element is not a member, do nothing. Comments? -- Gustavo Nieme