Revisiting PEP 505

I had participated a bit in one of the previous threads about this PEP a few months ago and had come to the realization that the ?. and ?[] operators both made a lot of intuitive sense if you instead treated the ? as a unary postfix operator

I’ll also add a shameless plug for a very long comment I made showing how the None-aware operators (and specifically just None-aware, not AttributeError or KeyError silencing) can be quite useful in a real world use case I have in my job doing analysis for a manufacturing company.

The overall point there is that if you are dealing with a entity-relationship model, long chains of attribute lookups are quite reasonable and in many cases it is an expected case that there could be a null value somewhere along the chain since relationships can be “total” (i.e. required/non-null) or “partial” (i.e. nullable) and the natural way to express that in Python is by using None

4 Likes