[Python-Dev] Short-circuiting iterators
Simon Wittber
simonwittber at gmail.com
Wed Dec 7 03:55:06 CET 2005
On 12/7/05, Raymond Hettinger <raymond.hettinger at verizon.net> wrote:
> [Matthew F. Barnes] Perhaps it would be a useful addition to the
> itertools
> > module then?
> >
> > itertools.interruptable(iterable)
>
> Any real-world use cases or compelling contrived examples?
I use something like this in the nanothreads module.
http://metaplay.dyndns.org:8081/svn/fibranet/fibranet/nanothreads.py
This feature is implemented in the Fibra class, in the end and kill
methods. It is used to stop an iterator from parts of the code which
are not part of the loop that is actually iterating the iterator.
This usage is specific to situations where generators are being used
as cooperative threads.
-Sw,
More information about the Python-Dev
mailing list