|
|
|
|
|
by SoftwareMaven
5138 days ago
|
|
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. |
|