Hello, I've not had much luck in searching for a discussion on this in the Python-Dev archives, so bear with me. I had an idea this morning for a simple extension to Python's iterator protocol that would allow the user to force an iterator to raise StopIteration on the next call to next(). My thought was to add a new method to iterators called stop(). In my situation it would be useful as a control-flow mechanism, but I imagine there are many other use cases for it: generator = some_generator_function() for x in generator: ... deeply ... ... nested ... ... control-flow ... if satisfaction_condition: # Terminates the for-loop, but # finishes the current iteration generator.stop() ... more stuff ... I'm curious if anything like this has been proposed in the past. If so, could someone kindly point me to any relevant mailing list threads? Matthew Barnes
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4