[Python-ideas] ternary without else

Rob Cliffe rob.cliffe at btinternet.com
Fri May 25 10:21:56 EDT 2018

On 25/05/2018 12:38, Steven D'Aprano wrote:
> PEP 8 is not holy writ. Ignore it when your code is better for ignoring
> it.
+1.  Not infrequently I judge that my code is easier both to read and to 
maintain with more than 1 (short) statement on a line,
often when it allows similar items to be aligned vertically.  A 
spur-of-the moment, totally invented example:
     if MON <= day <= FRI:    Rate = Normal
     if day==SAT:                     Rate = DoubleTime
     if day==SUN:                    Rate = TripleTime
I also feel no inhibitions about using Jacco's original example:
     if cond: do_something
Rob Cliffe

More information about the Python-ideas mailing list