In python I have:
c_f = None
#c_f may change here
if not c_f:
c_f = new_c_f
Can I write last 2 lines in one line?
If I want to keep first non-None value
If I want to keep last non-None value
Please Note that doing:
c_f = c_f or new_c_f
solves one of the cases
CodePudding user response:
Assuming you're trying to compress
if not c_f:
c_f = new_c_f
to one line, you can change it to a one-liner:
if not c_f: c_f = new_c_f