On Fri, 17 Dec 2021 09:25:03 +0100, ast <ast@invalid> wrote:
[snip]
>
> but:
>
> li = [grp for k, grp in groupby("aahfffddssssnnb")]
> list(li[0])
>
> []
>
> list(li[1])
>
> []
>
> It seems empty ... I don't understand why, this is
> the first read of an iterator, it should provide its
> data.

Baffling.  Here's a shorter and less readable illustration:


>>> list(groupby("aabbb"))
[('a', <itertools._grouper object at 0xb7018c0c>), 
 ('b', <itertools._grouper object at 0xb7018a0c>)]
>>> list(groupby("aabbb"))[0]
('a', <itertools._grouper object at 0xb71d3e4c>)
>>> list(list(groupby("aabbb"))[0][1])
[]


-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to