This is a problem I run into often, and am looking for the best solution. I will have code like this (python):
def func(var, opt):
if opt:
var = var.set_opt(opt)
result = var.get_result()
if opt:
return [r[0] for r in result] # arbitrary
else:
return result
What is a good, general practice, way to avoid this double if statement?