[Python-ideas] Why no dict.discard?
Laurens Van Houtven
_ at lvh.cc
Tue Aug 7 22:30:35 CEST 2012
FWIW I use d.pop(k, None) to mean "just remove this already regardless of whether or not it's present now".
cheers
lvh
On 07 Aug 2012, at 22:25, MRAB <python at mrabarnett.plus.com> wrote:
> The 'set' class has a 'discard' method, but dict doesn't.
>
> I know that I can just delete the key and catch the exception if it's
> absent, but I can also 'remove' a member from a set and catch the
> exception if it's absent, OR just 'discard' it to avoid an exception.
>
> How much interest would there be in adding 'discard' to dict too?
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
More information about the Python-ideas
mailing list