[issue34586] collections.ChainMap should have a get_where method
Zahari Dim
report at bugs.python.org
Tue Sep 11 16:21:27 EDT 2018
Zahari Dim <zaharid at gmail.com> added the comment:
>
> I've discussed this with other core devs and spent a good deal of time evaluating this proposal. I'm going to pass on the this one but do think it was a inspired suggestion. Thank you for the proposal.
Thank you for taking the time to consider it. I understand that there
are many proposals.
>
> ----------
>
> Note, the original get_where() recipe has an issue. Upon successful lookup, it returns a 2-tuple but on failure it calls __missing__ which typically returns a scalar (if it doesn't raise an exception).
FWIW this was intended to work when `__missing__` was subclassed to
raise a more specific exception. The case where it is made to return a
value clearly doesn't play well with the proposed method, and would
likely need to be subclassed as well. I consider this an acceptable
trade off because I find this use case rather esoteric: the same
functionality could be achieved in an arguably clearer way by passing
a mapping with the desired missing semantics as the outermost scope.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34586>
_______________________________________
More information about the Python-bugs-list
mailing list