I want to conditionally lazy evaluate a function with some heavy computations:
def fun(a):
yield a + 1
yield a * 2
Is it possible to write this exact function but with 1 line in the function body? Something like this:
def fun(a):
yield from (a+1, a*2)
But in the code snippet above I think the tuple will be evaluated eagerly? I only want to evaluate a*2
if necessary.