Chris Kaynor wrote: > On Mon, Feb 9, 2015 at 4:42 PM, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: >> so that's an excellent sign that doing so is best practice, but it should >> not be seen as *required*. After all, perhaps you have good reason for >> wanting your iterable class to only be iterated over once. > > In fact, there is one in the stdlib, the "file" object, which has a > __iter__ which returns self. The code below shows this, [...] > The "file" object is also an example of this. It is technically a > broken iterator according to the docs:
Awesome example! -- Steve -- https://mail.python.org/mailman/listinfo/python-list