I am looking for a code to copy the generator and then continue with the new generator. It is like a bifurcation of a generator.
def Generator():
myNumbers=range(3)
for i in myNumbers:
yield i
for i in Generator():
bifurcatedGenerator = Generator
for j in bifurcatedGenerator():
print (i, j)
this code gives as output:
0 0
0 1
0 2
1 0
1 1
1 2 <- wrong
2 0
2 1 <- wrong
2 2 <- wrong
whereas the disiered output should be: (The bifurcated generator needs to be a new instance, but continue at the same point as the old generator stopped.)
0 0
0 1
0 2
1 1
1 2
2 2
The application itself is much more complicated, this here is just a code example.
Important (only for myself) is a semanticly beautiful solution which is nicely readable to third parties.Efficiency is not so important