On 12/06/2013 05:14 PM, Dan Stromberg wrote:
> I'm thinking mostly of stackoverflow, but here's an example I ran into (a
> lot of) on a job:
> 
> somevar = some_complicated_thing(somevar) if
> some_other_complicated_thing(somevar) else somevar
> 
> Would it really be so bad to just use an if statement?  Why are we
> assigning somevar to itself?  This sort of thing was strewn across 3 or 4
> physical lines at a time.

You're right that a conventional "if" block is not only more readable,
but also faster and more efficient code.  Sorry you have to deal with
code written like that!  That'd frustrate any sane programmer.  It might
bother me enough to write code to reformat the program to convert that
style to something sane!  There are times when the ternary (did I get
that right?) operator is useful and clear.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to