3 ms·
> Generators have a "send()" method to push data in it. What would be the pythonic way of "mapping over" the inputs that are sent into a generator, or performi
by danidiaz 11y ago
> Generators have a "send()" method to push data in it.
What would be the pythonic way of "mapping over" the inputs that are sent into a generator, or performing grouping operations on those inputs?
For example, how to transform a generator that expects to be sent sets of strings into a generator that simply accepts a flat stream of strings?
- rob_smallshire 11y agoYou could use the python-transducer library <https://github.com/sixty-north/python-transducers> https://github.com/sixty-north/python-transducers> I mentioned in my other comments to do this. It supports using the same transducers with iterables and push-event coroutine generators.
- sametmax 11y agoYou don't, you chain small generators. Compositions of generators transforming data is the key.