Skip to content

Comment on The Python IAQ: Infrequently Answered Questionsparent

Comments

Incidentally, most C-style-syntax languages have a ternary conditional operator, and I use it quite a lot for things like building strings, very small conditionals, etc.... When used correctly, it can improve readability and expressiveness quite a bit.

x = <test> ? <result> : <alternative>

Some times for slightly more complex expressions, I'll put them on separate lines so as to have a very compact if/else structure.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.