Conditional expressions (again)

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Oct 25 21:32:42 EDT 2001


Erik Max Francis wrote:
> 
> gbreed at cix.compulink.co.uk wrote:
> 
> >                 x = b if a else (d if c else e)
> >
> Nested conditional expressions get extremely hard to read very quickly.

Write that as

   x = (
      b if a else
      d if c else
      e
   )

and it looks a lot clearer.

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list