On Wednesday 17 August 2016 06:59, Lawrence D’Oliveiro wrote: > On Wednesday, August 17, 2016 at 6:46:22 AM UTC+12, alister wrote: >> I don't think I am missing anything by not bothering with them YMMV > > Here > <http://ldo17.tumblr.com/post/17544419704/conditional-expressions-in-python> > are some examples of that varying mileage.
Quote: The Python syntax for conditional expressions (introduced in Python 2.5) is trueval if cond else falseval I think this is bloody awful. Why couldn’t they have adopted the standard C syntax, as used in a whole bunch of other C-derivative languages? cond ? trueval : falseval Because the C syntax is horrifically ugly, whereas the Python syntax is very close to real English syntax. "What will you do tonight?" "Go to the movies, if I finish work on time, otherwise just go home." Every time you read the C syntax, you lose another three minutes off your lifespan. That's how ugly it is. The background to the Python ternary operator is documented here: https://www.python.org/dev/peps/pep-0308/ Rather than ask why Python uses `trueval if cond else falseval`, you should ask why C uses `cond ? trueval : falseval`. Is that documented anywhere? -- Steve -- https://mail.python.org/mailman/listinfo/python-list