Code formatting question: conditional expression
Diez B. Roggisch
deets at nospam.web.de
Wed Aug 19 10:52:13 CEST 2009
> BTW, from the (admittedly few) responses to my original post, it seems
> there's some sentiment that "conditional expressions" are a non-Pythonic
> misfeature. Interesting ...
No. I love them. But not if they are so large that they stretch over several
lines (or to many columns).
foo = bar if cond else baz
is more than fine for me. But
foo = I_need_to_do_something_really_complicated_here() if cond else baz
isn't, because one doesn't grasp as easily in one look that we're talking a
ternary operator here.
More information about the Python-list