On 12/7/2013 11:13 AM, Rotwang wrote:
On 07/12/2013 12:41, Jussi Piitulainen wrote:
[...]
if tracks is None:
tracks = []
Sorry to go off on a tangent, but in my code I often have stuff like
this at the start of functions:
tracks = something if tracks is None else tracks
or, in the case where I don't intend for the function to be passed
non-default Falsey values:
tracks = tracks or something
Is there any reason why the two-line version that avoids the ternary
operator should be preferred to the above?
The 'extra' line is not necessary, as one can write
if tracks is None: tracks = [] # or something
I prefer this because it exactly expresses what one want done. The other
branch
else: tracks = tracks
is superfluous and to me unaesthetic.
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list