in search of graceful co-routines
Chris Withers
chris at simplistix.co.uk
Wed May 18 01:27:15 EDT 2011
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
More information about the Python-list
mailing list