Python Forum
iterating an interator partially then resuming
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
iterating an interator partially then resuming
#4
looks like i have a case where the item i got from the iterator needs to be put back in the iterator so the 2nd loop processes that item again. this case is iterating over some command line arguments and breaking out when it hits a filename. then the 2nd loop finishes the filenames.

i also wonder if i could iterate nested. that is a deeper loop inside the outer loop with both loops iterating over the same iterator ... so the inner one can work on more than one item. but i'd still like to have the last item pushed back into/onto the iterator. i have been doing this in the past by make a list from the iterator then where needed, inserting items into the front of the list. but this all involved more code to handle details like popping items from a list inside a while True: loop.
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
RE: iterating an interator partially then resuming - by Skaperen - Apr-30-2019, 03:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [3.4.4] Last loop element partially done nolme 5 3,099 May-08-2018, 03:25 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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