[Matthew F. Barnes]
> The ability to remotely terminate a for-loop also struck me as
somewhat
> interesting:
>
> def estimate(item, iterable):
> . . .
> if good_enough:
> iterable.stop()
> return result
>
> for x in iterable:
> . . .
>
On Tue, 2005-12-06 at 19:58 -0500, Raymond Hettinger wrote:
> Any real-world use cases or compelling contrived examples?
>
> ISTM, that the code calling it.stop() would already be in position to
> break-out of the iteration directly or set a termination flag. Instead
> of:
>
> it = itertools
On 12/7/05, Raymond Hettinger <[EMAIL PROTECTED]> wrote:
> Are there any generator specific needs that are not met by the PEP 342
> implementation? Given a choice between throw(), close(), and send(), I
> would have thought that all the bases have been covered.
Agreed. When the new functionality
[Matthew F. Barnes]
> > > Perhaps it would be a useful addition to the itertools
> > > module then?
> > >
> > > itertools.interruptable(iterable)
[Raymond Hettinger]
> > Any real-world use cases or compelling contrived examples?
[Simon Wittber]
> I use something like this in the nanothr
On 12/7/05, Raymond Hettinger <[EMAIL PROTECTED]> 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 th
[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?
ISTM, that the code calling it.stop() would already be in position to
break-out of the iteration dir
On Wed, 2005-11-30 at 14:36 -0500, Edward Loper wrote:
> There's no need to change the iterator protocol for your example use
> case; you could just define a simple iterator-wrapper:
Good point. Perhaps it would be a useful addition to the itertools
module then?
itertools.interruptable(
> I had an idea this morning for a simple extension to Python's iterator
> protocol that would allow the user to force an iterator to raise
> StopIteration on the next call to next(). My thought was to add a new
> method to iterators called stop().
There's no need to change the iterator protocol
On Wed, 2005-11-30 at 10:57 -0800, Alex Martelli wrote:
> PEP 342, already accepted and found at
> http://python.org/peps/pep-0342.html , covers related functionality
> (as well as many other points).
Thanks Alex, I'll take another look at that PEP. The first time I tried
to read it my brain star
On 11/30/05, Matthew F. Barnes <[EMAIL PROTECTED]> wrote:
...
> I'm curious if anything like this has been proposed in the past. If so,
> could someone kindly point me to any relevant mailing list threads?
PEP 342, already accepted and found at
http://python.org/peps/pep-0342.html , covers rel
10 matches
Mail list logo