Raymond Hettinger <raymond.hettin...@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. ---------- 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). The proposed use case is plausible but rare. As Serhiy mentioned, it is also reasonable for the user to write their own loops over the *maps* attribute. That loop can have subtleties but it is better to let the user choose between try/except semantics and if-else semantics according to the use case. FWIW, I tried out several variants of the proposal including "cm.index(key) -> int" and "cm.search(key) -> mapping". Each of the variants had some awkwardness when trying to use it there didn't seem to be a variant that was a net win. ---------- resolution: -> rejected stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34586> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com