On 23 September 2015 at 17:47, Steven D'Aprano firstname.lastname@example.org wrote:
I've now read PEP 505, and I would like to comment.
Having read the various messages in this thread, and then your summary (which was interesting, because it put a lot of the various options next to each other) I have to say:
1. The "expanded" versions using if..else are definitely pretty unreadable and ugly (for all the variations). But in practice, I'd be very unlikely to use if expressions in this case - I'd be more likely to expand the whole construct, probably involving an if *statement*. Comparing a multi-line statement to an operator is much harder to do in a general manner. So I guess I can see the benefits, but I suspect the operators won't be used in practice as much as people are implying (in much the same way that the use if the if expression is pretty rare in real Python code, as opposed to examples).
2. All of the punctuation-based suggestions remain ugly to my eyes. ? is too visually striking, and has too many other associations for me ("help" in IPython, and as a suffix for variable names from Lisp). Nick's || version looked plausible, but the inconsistent !| variations bother me.
3. People keep referring to "obj ?? default" in comparison to "obj or default". The comparison is fine - as is the notion that we are talking about a version that simply replaces a truth test with an "is None" test. But to me it also says that we should be looking for a keyword, not a punctuation operator - the "or" version reads nicely, and the punctuation version looks very cryptic in comparison. I can't think of a good keyword, or a viable way to use a keyword for the ?. ?[ and ?( variations, but I wish I could.
Summary - I don't mind the addition of the functionality, although I don't think it's crucial. But I really dislike the punctuation. The benefits don't justify the cost for me.