Defending the ternary operator
Andrew Dalke
adalke at mindspring.com
Mon Feb 10 02:05:40 EST 2003
Paul Paterson
> Continuing the experiment to look at Python code which might use the
> conditional operator....
>
> If my regular expression is correct (and it probably isn't because I'm not
> good at them), then a quick scan of my Python22 directory structure finds
> 769 matches of the following pattern,
>
> if <something>
> variable = <some value>
> else:
> variable = <some other value>
Oh yeah, and you should also check for
if <something>:
return <some value>
return <some other value>
Which is also more common in C code compared to
return something ? some_value : some_other_value;
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list