Can I suggest that next() and __next__() be dropped entirely  and that 
iterators just be made callable.  The current approach seems to make people 
think there is something wrong with using an iterator directly (inside of in a 
for-loop or function that consumes an iterator.

>>> ### What we do now
>>> import itertools
>>> count = itertools.count(1).next
>>> count()
1
>>> count()
2


>>> ### What would be nice
>>> import itertools
>>> cnt = itertools.count(1)
>>> cnt()
1
>>> cnt()
2
>>> def f(x):
...    while x > 1:
...        yield x
...        if x % 2 == 0:
...            x //= 2
...        else:
...            x = x * 3 + 1
...
>>> g = f(12)
>>> g()
12
>>> g()
6
>>> g()
3
>>> g()
10




Raymond Hettinger
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to