Why does an iterator in python 3 support __next__
and not next
? Is it not supposed to be called directly but only while doing :
for i in iterator:
dosomething(i)
I have a use case where I would like to call next
. For example using itertools.count
for a stream of increasing integers. I would like to do :
from itertools import count
cnt = count(0)
one(cnt.next())
two(cnt.next())
Right now I can do the above by using __next__
which suggests to me that it is supposed to not be called externally?