←back to thread

160 points leontrolski | 1 comments | | HN request time: 0.197s | source
Show context
cpburns2009 ◴[] No.41887804[source]
For all of the syntax features Python has been adding over the years, this would be a nice enhancement: making the "else None" optional in the ternary if-expression. E.g.,

    spam = eggs if bar
    # vs
    spam = eggs if bar else None
replies(3): >>41887917 #>>41887943 #>>41888372 #
1. kstrauser ◴[] No.41888372[source]
I almost never use None as the second value here. From my POV, that would be new syntax for an unlikely situation.