How do we yield from another sub-generator, but with transformation/processing?
for example: in code below, main_gen yields x after transformation using f(x)
def f(x):
return 2*x
def main_gen():
for x in sub_gen():
yield f(x)
can this be replaced with yield from and if so how?
def main_gen():
yield from ***
You could do:
But then, why not:
Which is a lazy iterator anyway.