Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5652 > unrolled thread
| Started by | Chris Withers <chris@simplistix.co.uk> |
|---|---|
| First post | 2011-05-18 06:27 +0100 |
| Last post | 2011-05-18 06:27 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: in search of graceful co-routines Chris Withers <chris@simplistix.co.uk> - 2011-05-18 06:27 +0100
| From | Chris Withers <chris@simplistix.co.uk> |
|---|---|
| Date | 2011-05-18 06:27 +0100 |
| Subject | Re: in search of graceful co-routines |
| Message-ID | <mailman.1740.1305696432.9059.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web