hn • r/hackernews
Comment on: New Ways to Be Told That Your Python Code Is Bad
In practice, quitRequested and processNextEvent are probably both members of some managerial object; perhaps like this: while not loop.quit_requested:
process(loop.next_event())
And when you see it like that, then it becomes more apparent there’s an obvious way for it to be an iterator: for event in loop.run():
process(event)
This is typically harder to get wrong, and generally matches the semantics of what you’re trying to do more closely: process a stream of events. You didn’t actually care about quit_requested, you cared about the events.And so in this you can start to see w