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 -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/G53YRFAZG3RDUPBZKHAFR2XH4DONTFAU/
Code of Conduct: http://python.org/psf/codeofconduct/