On Aug 2, 2019, at 15:45, Steven D'Aprano email@example.com wrote:
Are infinite for-loops that common that people get excited by cycle? That sounds like the "here's a hammer, now every problem is a nail" issue. "itertools.cycle is cool, I must use it as often as possible!"
Well, they’re probably excited that the function they spent the last three hours debugging some fence post error on can be replaced by a single line, not that every program for the rest of their life will be similarly improved.
(Once you get the itertools way of doing things, a whole lot of programs for the rest of your life _are_ similarly improved. But I don’t think cycle is enough to get that across. If someone wants to learn more, I usually point them to… I don’t have the links with me, but it’s Generator Tools for Systems Programmers v2, and something that was part of the pitch for yield from that I can’t remember.)