News for hackers. Stuff that matters.
Re:A few things to remember while coding in Python by SoftwareMaven on Sunday May 20, 2012 @05:07PM (#4000109)
Because that "if" is a statement whereas the ternary expression is, well, an expression. There are places expressions can be used that statements can't (eg lambdas) and that x or [] won't work (eg when x is False).

That said, people still seem to favor your form as the more Pythonic way. Personally, I think that's just because the ternary expression is relatively new.

There are no comments on this comment yet.