spacepaste
new
Paste details
reply
|
raw
def
works
(
it
):
while
True
:
yield
[
next
(
it
)
for
_
in
xrange
(
2
)]
def
notworks
(
it
):
while
True
:
yield
list
(
next
(
it
)
for
_
in
xrange
(
2
))
print
list
(
works
(
iter
([
1
,
2
,
3
,
4
,
5
])))
# will never return
print
list
(
notworks
(
iter
([
1
,
2
,
3
,
4
])))