single-line terinary operators considered harmful
OKB (not okblacke)
BrenBarn at aol.com
Mon Mar 10 11:33:41 EST 2003
Clark C. Evans wrote:
> After the select/case option presented previously, my second
> best option would be something like...
>
> var = (if 1 == x: 'yes'
> else: 'no')
>
> Where the 'else' must be in the same column as the
> corresponding if.
Personally I find this frightening. I don't like the idea of an
indent level being defined by non-whitespace characters. Here, the "var
= (" is defining the indent level for the else. This is, to me, a bad
thing, because, if you just look at this line:
var = (if 1 == x: 'yes'
. . . it's not immediately obvious what the "correct" column is for
the else.
--
--OKB (not okblacke)
"Do not follow where the path may lead. Go, instead, where there is
no path, and leave a trail."
--author unknown
More information about the Python-list
mailing list