[Python-ideas] Add "default" kwarg to list.pop()

Michael Selik mike at selik.org
Wed Oct 31 16:29:35 EDT 2018


On Wed, Oct 31, 2018 at 12:31 PM Chris Angelico <rosuav at gmail.com> wrote:

> What is being asked for here (if I'm not misreading) is a relatively simple
> enhancement to a method on a built-in type (or a small handful of
> types). If that garners reasonable support, the next step wouldn't be
> a PEP, it'd just go straight to a tracker issue and a pull request.
>
> For myself, I'm +0 on adding default=. It'd be a minor convenience on
> a very small number of cases. But it wouldn't bother me at all so it
> wouldn't be a problem if it were to land.
>

If the consensus is to add a default keyword parameter for the rest of the
get/pop methods on built-in types, it'd be reasonable to write an addendum
to PEP 463 that mentions what is being established as the Pythonic
interface: When a method can raise IndexError or KeyError, the method
should provide an optional default which suppresses the error.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20181031/b1e4cecb/attachment.html>


More information about the Python-ideas mailing list