My first thought was next(), which I use occasionally:
>>> items = (i for i in range(9)) >>> items <generator object <genexpr> at 0x7f33251766d0> >>> first, second = next(items), next(items) # 👀 >>> first, second (0, 1) >>> tuple(items) (2, 3, 4, 5, 6, 7, 8) No imports needed. Is this deficient for the use case in some way? -Mike
On Fri, Jun 17, 2022 at 11:32:09AM -0000, Steve Jorgensen wrote:
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/G53YRFAZG3RDUPBZKHAFR2XH4DONTFAU/ Code of Conduct: http://python.org/psf/codeofconduct/