Alex Hall writes:
> On Wed, Aug 26, 2020 at 5:00 PM Stephen J. Turnbull <
> turnbull.stephen.fw@u.tsukuba.ac.jp> wrote:
>
> > If the "keyword arguments in __getitem__" feature is added, .get() is
> > purely redundant. (Of course this thread would then become "make
> > 'default' a standard keyword argument for mutable collections.")
> >
>
> Is that something people want to do? Do people want to be able to
> write `my_dict[key, default=0]` instead of `my_dict.get(key, 0)`?
> What about `my_dict[key, default=None]` instead of `my_dict.get(key)`?
Of course they don't want to do that. Of course dict.get is going
nowhere. Of course that's redundant. Of course if collections get a
standard 'default' for __getitem__, many people *will* start writing
`my_dict[key, default=None]`, if only because they don't read enough
docs to know about dict.get.
OK, I'll try again. Do people want collections to get a standard 'default' for `__getitem__`?
I don't want mappings to grow a second way to do the same thing, and I don't want sequences to have a different way to do it from mappings.