Skip to content

Comment on The Python IAQ: Infrequently Answered Questionsparent

Comments

It's worth noting that Peter himself mentions that most of the ternary tricks he describes are not very readable and wouldn't be considered Pythonic.

   Beautiful is better than ugly.
   Explicit is better than implicit.
   Simple is better than complex.
Personally I'd hate to see something like that in any real-world project.
   (test and [result] or [alternative])[0]

Depending on the language, it could be an idiom.

AboutSource Built by g1lg1l

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