spacepaste

  1.  
  2. def works(it):
  3. while True:
  4. yield [next(it) for _ in xrange(2)]
  5. def notworks(it):
  6. while True:
  7. yield list(next(it) for _ in xrange(2))
  8. print list(works(iter([1,2,3,4,5])))
  9. # will never return
  10. print list(notworks(iter([1,2,3,4])))
  11.