
24 Jun
2020
24 Jun
'20
3:36 p.m.
Guido van Rossum wrote:
So why not .get(key, <sentinel>)? You can reuse the sentinel, and this way it's a single call instead of two -- e.g. the code in Mapping implements both __contains__() and get() by calling __getitem__() and catching KeyError.
Good point. Another option I've considered is using the `keys` method, since most non-dict mappings would get this called anyways for patterns with `**rest`.
All the more reason why we should allow the implementation some flexibility. ;)