Quantcast
Channel: Python create an iterator/generator with feedback - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by Olivier Melançon for Python create an iterator/generator with feedback

Did you that you can send to a generator using generator.send? So yes, you can have a generator to change its behaviour based on feedback from the outside world. From the...

View Article



Answer by OregonJim for Python create an iterator/generator with feedback

def conditional_iterator(y): # stuff to create new values yield x if (expression involving y) else another_xfor x in conditional_iterator(y): y = some_computation(x)

View Article

Answer by Nathan Werth for Python create an iterator/generator with feedback

It's possible but confusing. If you want to keep the sequence of x values and the calculations on x separate, you should do this explicitly by not involving x with an iterator.def...

View Article

Python create an iterator/generator with feedback

Is it possible to create a iterator/generator which will decide on the next value based on some result on the previous iteration?i.e.y = Nonefor x in some_iterator(ll, y): y = some_calculation_on(x)I...

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images