Python Forum
how to join 2 iterators - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how to join 2 iterators (/thread-21050.html)



how to join 2 iterators - Skaperen - Sep-11-2019

you can join 2 lists with the + operator. but now we are getting iterators where we once got lists. usually they are effectively the same. but the + operator does not create a new iterator referencing the 2 iterators around it. is there a standard way to join 2 iterators? ideally, it would be able to handle more than 2 and a mix of iterators and sequences. if not, then i guess i need to code up another generator.


RE: how to join 2 iterators - buran - Sep-11-2019

itertools.chain


RE: how to join 2 iterators - Skaperen - Sep-11-2019

thank you!!