Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: