On Mon, 5 Mar 2007 [EMAIL PROTECTED] wrote: > Can I suggest that next() and __next__() be dropped entirely > and that iterators just be made callable.
We went through a long discussion about this when iterators were being figured out the first time around -- in fact, using __call__ was the original proposal, and then it was changed to __next__. I imagine we must have had good reasons for it. PEP 234 (it amuses me that the PEP number for iterators is three digits in arithmetic sequence) says: Arguments against __call__() (the original proposal): taken out of context, x() is not very readable, while x.next() is clear; there's a danger that every special-purpose object wants to use __call__() for its most common operation, causing more confusion than clarity. I think __next__ is better than __call__ because EIBTI. It's a lot more obvious that you're doing explicit iteration (and have all the expectations that go along with it) when you see the call to the next built-in (or method). Explicit iteration (calling next) is quite a bit less common than implicit iteration (with for loops), so it's probably a good idea for it to have a distinct look to it. Function calls happen all over the place; it would be easy not to notice that iteration is occurring with an x() call buried among lots of other stuff. -- ?!ng _______________________________________________ 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