Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
coroutines
#1
today i am working on a project that probably should be a coroutine.  it takes in a list of strings.  it is expected that this list is very long.  it can be a tuple (it is not modified).  a page of a series of columns is constructed.  the order runs down each column until the bottom of the page, then another column is started.   as soon as a next column cannot fit on the page, then the page is done and a new page is started and the "next column" is the first column of the new page.  for now the whole list is passed to the function and the returned result is a list of pages.  each page is a list of strings that make up the formed lines of the page, ready to print.  also passed to the function is page geometry info assuming fixed sized characters: page width, page height, and gutter space between columns.  i am thinking that the usefulness of this can be expanded if it is a coroutine, or a generator that has data "sent" to it.  but i have not seen ... cannot find .. complete examples of this kind of thing (even if the example is something that we would never do as a coroutine).   my coroutine would be initialized with that geometry information then given one string at a time.  as soon as a page is complete, it would be yielded to the caller.  so i am looking for complete (shows both sides, fully ... how data is received and sent) examples (small, not filled with complexity of the example purpose).

a simple example i can imagine is a coroutine that adds all numbers it receives, and yields the running sum.  but an example needs to also show the use ... the other end ... the caller.
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
coroutines - by Skaperen - Feb-03-2017, 01:46 AM
RE: coroutines - by Mekire - Feb-03-2017, 12:10 PM
RE: coroutines - by Skaperen - Feb-04-2017, 02:19 AM
RE: coroutines - by ichabod801 - Feb-03-2017, 10:29 PM
RE: coroutines - by wavic - Feb-03-2017, 11:03 PM
RE: coroutines - by Larz60+ - Feb-04-2017, 04:15 AM
RE: coroutines - by Skaperen - Feb-04-2017, 04:52 AM
RE: coroutines - by wavic - Feb-04-2017, 10:21 AM
RE: coroutines - by snippsat - Feb-04-2017, 11:03 AM
RE: coroutines - by wavic - Feb-04-2017, 11:17 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  error in Linking two coroutines shankar 3 5,575 Jun-19-2020, 06:50 PM
Last Post: gogawaleankita

Forum Jump:

User Panel Messages

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