Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • True, somehow I'm still missing the yield solution that smells right to me for a Python-style inversion of control / separation of the thing producing the items to be iterated over, vs. the thing processing the yielded items. Commented Jan 28 at 20:12
  • 2
    @JasonS You can replace the handler calls with yields in the above. It's totally normal valid to emit everything and then filter what you don't want. If the cost of that is low, I would do that. But if you want to avoid the cost of creating things in the scanner that you don't need, that logic needs to happen in the scanner. Passing in a filtering function (or object) is a kind of IoC that is pretty standard in Python. Commented Jan 28 at 20:26