Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5652
| Date | 2011-05-18 06:27 +0100 |
|---|---|
| From | Chris Withers <chris@simplistix.co.uk> |
| Subject | Re: in search of graceful co-routines |
| References | <4DD2AA99.3010508@simplistix.co.uk> <BANLkTin228brtPfuRrsEqscO1015gVKCTw@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1740.1305696432.9059.python-list@python.org> (permalink) |
On 17/05/2011 18:26, Ian Kelly wrote:
> You can use send the way you're wanting to. It will look something like this:
>
> def provider():
> result = None
> while True:
> if result is None:
> if has_more_items():
> next_item = get_next_item()
> else:
> break
> elif result == 'fail':
> process_fail()
> next_item = None
> elif result == 'succeed':
> process_succeed()
> next_item = None
> else:
> raise ValueError('unknown result %s' % result)
> result = (yield next_item)
Yes, but it's this kind of birds nest I'm trying to avoid...
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: in search of graceful co-routines Chris Withers <chris@simplistix.co.uk> - 2011-05-18 06:27 +0100
csiph-web