Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
a "consuming-generator"
#1
a concept and coding scheme i once created in C (as well as C could do this) i would (now days) call a "consuming-generator". but it was really more like a "filter". basically, it accepted a sequence of data items from the caller and returned new data items to the caller. in both cases this was done in C by the code calling a function, passing it some data, or not (if there wasn't any but the caller was just checking for any). then the function would return some data, or not (if there wasn't any to return). a totally different thing was used to give or take an EOF. i wrote a couple filters this way, one of which did some run-length compression, so it would be given more data than it gave back.

in python, i don't think a generator can do this. but maybe a co-routine could. has this kind of thing been done? are there any helper modules for it?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Messages In This Thread
a "consuming-generator" - by Skaperen - Sep-07-2019, 03:00 AM
RE: a "consuming-generator" - by ndc85430 - Sep-07-2019, 05:01 AM
RE: a "consuming-generator" - by Skaperen - Sep-07-2019, 05:31 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020