
I looked at the PEP for None-aware operators and I really feel like they miss one important detail of Python's data model:
{}[0] Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: 0 [][0] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range
that is: missing items raise, rather than being None. as such I feel like None-aware operators would encourage ppl to put None everywhere, which from what I can tell, goes completely against Python's data model. however, exception-aware operators could be a potential alternative that: 1. works with existing code (no need to go shoving None everywhere) 2. works in lambdas 3. ends up being more useful? I don't know what the potential syntax would look like. perhaps something along the lines of: exception-raising-expression ?: value-if-exception-raised or: exception-raising-expression ? (IndexError, KeyError, Etc) : value-if-exception-raised but, thoughts?