On May 20, 2:35 pm, Jan <jan.pl...@plattsburgh.edu> wrote: OOPS, I have pressed some keys and the message went out before It was finished. Here is the last fragment:
So, one can define iterators by defining a class whose objects have methods __iter__ and __next__ -- with this approach it is easy to add some __reset__ method. But the easiest way to define iterators is by constructing a generating function (with yield expressions); this function returns iterators, although without __reset__. Another way to define an iterator is to define callable and using iter(CALLABLE, SENTINEL) -- the resulting iterator will not have __reset__. I do not know how Python is implemented but I believe that in the last two cases, Python could produce improved iterators with __reset__ at almost no additional cost. Jan -- http://mail.python.org/mailman/listinfo/python-list