Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
repeating a range
#6
the case i have is a caller creates the range object and passes it and other parameters to a function. the function can accept any iterator in place of the range. that function iterates that iterator repeatedly until a condition is met. the function may be designed as a generator in which the yield statement may be inside or outside the body of that iteration. it is not at simple as a number being provided or determined then repeating the iteration that many times. however, a design around a number may be a simple way to test iterator object management.

the code for this has not been written. all the design ideas in a project had this need and i was trying to work around that need and could not. but, since iter() can do this, all the function should need to do is hang on to the original iterator/range and make transient copies with iter() and use those results each time.

it might be convenient to have a quick means to get a count of the number of times an iterator should step through its range without having to literally run it. for range(), this can be calculated. for other things, such as an iterator reading a network connection, it may be impossible.
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
repeating a range - by Skaperen - Aug-09-2022, 06:42 PM
RE: repeating a range - by Yoriz - Aug-09-2022, 07:03 PM
RE: repeating a range - by Gribouillis - Aug-09-2022, 09:02 PM
RE: repeating a range - by Skaperen - Aug-09-2022, 11:26 PM
RE: repeating a range - by DeaD_EyE - Aug-10-2022, 09:44 AM
RE: repeating a range - by Skaperen - Aug-10-2022, 10:17 PM

Forum Jump:

User Panel Messages

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