Cleaning up conditionals
python at deborahswanson.net
Fri Dec 30 23:03:46 EST 2016
Michael Torrie wrote:
> On 12/30/2016 05:26 PM, Deborah Swanson wrote:
> > I'm still wondering if these 4 lines can be collapsed to one or two
> > lines.
> If the logic is clearly expressed in the if blocks that you
> have, I don't see why collapsing an if block into one or two
> lines would even be desirable. Making a clever one-liner out
> of something isn't always a good thing. In fact some
> programmers don't like to use the ternary operator or
> conditional expressions, preferring to use explicit if block logic.
Maybe it isn't always a good thing, but learning the capabilities of
python is. Besides, if the concern is future maintenance, a lot would
depend on the proficiency of those expected to maintain the code.
More information about the Python-list