Defending the ternary operator
Carlos Ribeiro
cribeiro at mail.inet.com.br
Mon Feb 10 20:59:34 EST 2003
On Monday 10 February 2003 14:03, Laura Creighton wrote:
> Jeremy Fincher
> > I may be alone in this, but I find
> >
> > if condition:
> > do_something()
> >
> > To be significantly more readable than:
> >
> > if condition: do_something()
>
> [snip]
>
> You aren't alone. Far from it.
I agree with it, as far as the test is really a 'control condition'. But
sometimes we do need simple tests - I call them 'auxiliary tests', for small
stuff such as making an option to write out 'item' or 'items', or selecting
alternate colors for a report. Having all those tests unfolded only serves to
make the logic less readable. That's why I like them as conditional
expresssions.
--
Carlos Ribeiro
cribeiro at mail.inet.com.br
More information about the Python-list
mailing list