Phillip J. Eby wrote: > At 01:58 PM 5/6/2005 +1000, Delaney, Timothy C (Timothy) wrote: > >>Personally, I'm of the opinion that we should make a significant break >>(no pun intended ;) and have for-loops attempt to ensure that iterators >>are exhausted. > > > This is simply not backward compatible with existing, perfectly valid and > sensible code. > Therefore, this can't happen till Py3K. > > The only way I could see to allow this is if: > > 1. Calling __iter__ on the target of the for loop returns the same object > 2. The for loop owns the only reference to that iterator. > > However, #2 is problematic for non-CPython implementations, and in any case > the whole thing seems terribly fragile.
Is it better to have: 1. A single looping construct that does everything, 2. or several more specialized loops that are distinct? I think the second may be better for performance reasons. So it bay would better to just add a third loop construct just for iterators. a. for-loop -->iterable sequences and lists only b. while-loop --> bool evaluations only c. do-loop --> iterators only Choice c. could mimic a. and b. with an iterator when the situation requires a for-loop or while-loop with special handling. Ron_Adam _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com