I'm taking an online Python course. One of the exercises contains:
[print(x, 'has type', type(eval(x))) for x in ['np_vals', 'np_vals_log10', 'df', 'df_log10']]
To me, this long statement is less readable than a standard loop, e.g.,
for x in ['np_vals', 'np_vals_log10', 'df', 'df_log10'] :
print(x, 'has type', type(eval(x)))
Is there some kind of recommended practice against this kind of thing?
I write long lines in bash to take advantage of piping and substitution, and so that I can cobble and edit the whole using the vi input mode -- but I do so knowing that it would be written differently for readability in a script.