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


Groups > comp.lang.python > #5652

Re: in search of graceful co-routines

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@simplistix.co.uk>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'elif': 0.04; 'subject:search': 0.07; 'python': 0.08; 'kelly': 0.09; 'none:': 0.09; 'this:': 0.10; 'def': 0.12; 'wrote:': 0.14; 'from:addr:simplistix.co.uk': 0.16; 'from:name:chris withers': 0.16; 'message-id:@simplistix.co.uk': 0.16; 'received:89.151': 0.16; 'received:89.151.125': 0.16; 'received:89.151.125.140': 0.16; 'received:server1.simplistix.co.uk': 0.16; 'received:simplistix.co.uk': 0.16; 'result)': 0.16; 'cc:addr :python-list': 0.17; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'trying': 0.23; "i'm": 0.27; 'raise': 0.28; 'cc:addr:python.org': 0.30; 'from:addr:chris': 0.30; 'wanting': 0.32; 'break': 0.33; 'chris': 0.34; 'header:User-Agent:1': 0.35; 'none': 0.37; 'something': 0.37; 'processing': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'received:192': 0.38; 'received:192.168.1': 0.40; 'kind': 0.60; 'url:co': 0.62; 'received:89': 0.68; 'batch': 0.68; 'birds': 0.84
Date Wed, 18 May 2011 06:27:15 +0100
From Chris Withers <chris@simplistix.co.uk>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10
MIME-Version 1.0
To Ian Kelly <ian.g.kelly@gmail.com>
Subject Re: in search of graceful co-routines
References <4DD2AA99.3010508@simplistix.co.uk> <BANLkTin228brtPfuRrsEqscO1015gVKCTw@mail.gmail.com>
In-Reply-To <BANLkTin228brtPfuRrsEqscO1015gVKCTw@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Cc Python <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1740.1305696432.9059.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 82.94.164.166
X-Trace 1305696432 news.xs4all.nl 49177 [::ffff:82.94.164.166]:48082
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5652

Show key headers only | View raw


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


Thread

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

csiph-web