On Mon, Jul 23, 2018 at 11:52 AM Steve Dower <steve.do...@python.org> wrote:
> I'm borderline on ?[] right now. Honestly, I think it works best if it > also silently handles LookupError (e.g. for traversing a loaded JSON > dict), but then it's inconsistent with ?. which I think works best if it > handles None but allows AttributeError. That would easily make typos pass unnoticed: request.context.user.usernme # raises AttributeError request?.context?.user?.usernme # return None Same goes for LookupError: if a key or index is missing on 'a?[b]' I do want an exception. If I don't, which should be the exception rather than the rule, I will simply take the risk myself and do: default = '<no name>' try: name = d['user']['details']['name'] or default except KeyError: name = default But certainly there should be no native syntax encouraging me to do any of that. Talking about arbitrarily swallowing exceptions is the worst direction this proposal can take as it breaks yet another fundamental Python Zen: "errors should never pass silently". IMO this shows how fundamentally detached from the base philosophy of the language this whole idea is. -- Giampaolo - http://grodola.blogspot.com _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/