Unerwartetes Verhalten von itertools.groupby
Dies ist das beobachtete Verhalten:
In [4]: x = itertools.groupby(range(10), lambda x: True)
In [5]: y = next(x)
In [6]: next(x)
---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
<ipython-input-6-5e4e57af3a97> in <module>()
----> 1 next(x)
StopIteration:
In [7]: y
Out[7]: (True, <itertools._grouper at 0x10a672e80>)
In [8]: list(y[1])
Out[8]: [9]
Die erwartete Ausgabe vonlist(y[1])
ist[0,1,2,3,4,5,6,7,8,9]
Was ist denn hier los
Ich habe dies am @ beobachtcpython 3.4.2
, aber andere haben dies mit @ gesehcpython 3.5
undIronPython 2.9.9a0 (2.9.0.0) on Mono 4.0.30319.17020 (64-bit)
.
Das beobachtete Verhalten aufJython 2.7.0
und pypy:
Python 2.7.10 (5f8302b8bf9f, Nov 18 2015, 10:46:46)
[PyPy 4.0.1 with GCC 4.8.4]
>>>> x = itertools.groupby(range(10), lambda x: True)
>>>> y = next(x)
>>>> next(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
>>>> y
(True, <itertools._groupby object at 0x00007fb1096039a0>)
>>>> list(y[1])
[]