Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #5652 > unrolled thread

Re: in search of graceful co-routines

Started byChris Withers <chris@simplistix.co.uk>
First post2011-05-18 06:27 +0100
Last post2011-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.


Contents

  Re: in search of graceful co-routines Chris Withers <chris@simplistix.co.uk> - 2011-05-18 06:27 +0100

#5652 — Re: in search of graceful co-routines

FromChris Withers <chris@simplistix.co.uk>
Date2011-05-18 06:27 +0100
SubjectRe: 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web