What are the iteration class methods next() and __next__() for, and what is the difference?

后端 未结 2 1213
误落风尘
误落风尘 2021-01-17 15:13

I am a little bit lost on python iterators. I occasionally use them, but I don\'t remember creating one myself. I read from somewhere that I don\'t remember where, a code li

2条回答
  •  既然无缘
    2021-01-17 16:03

    next has been renamed to __next__ in Python 3. As for what it does, it should return the next item, or raise StopIteration if there are no more.

提交回复
热议问题