Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
uniterate
#1
i have a big iteration loop like for item in myiterable: followed by a lot of indented code. in that loop body i test item for many possible cases to define what follows it (what comes later in the iterable). i have run into a couple cases where it ends up with the next item that needs to go through the loop. if i could have it "push" the item back into the iterable just before it falls to the end of the loop to go back around and have that item pulled back from the iterable by the operation of for item in myiterable: then that would be an instant solution. it sounds like i need a stackable iterable. is there a way to do that?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Skaperen Wrote:if i could have it "push" the item back into the iterable
Have a look at more_itertools.peekable() for example.
Reply


Forum Jump:

User Panel Messages

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