Path: csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'syntax': 0.04; 'statements': 0.09; 'thus,': 0.09; 'def': 0.12; 'itself.': 0.14; '"global"': 0.16; 'block.': 0.16; 'coroutines': 0.16; 'expecting': 0.16; 'false:': 0.16; 'generator.': 0.16; 'pythonic': 0.16; 'stumbled': 0.16; 'subject:generator': 0.16; 'worse.': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'later': 0.20; 'separate': 0.22; 'mon,': 0.24; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'am,': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'bugs': 0.33; 'could': 0.34; 'received:google.com': 0.35; 'add': 0.35; 'really': 0.36; 'keyword': 0.36; 'yield': 0.36; 'being': 0.38; 'to:addr:python- list': 0.38; 'realize': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'even': 0.60; 'ian': 0.60; 'back': 0.62; 'more': 0.64; 'mar': 0.68; 'special': 0.74; '2015': 0.84; 'glance': 0.84; 'won': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ga1lXShVb86drPhBo4uhuhrJLvEJ/anzPD59u9lidks=; b=dRqhMRlf6H4R1h49HAqCLUC4cADUGUSTIo6Uy63zU4bsTPE8Z3Ld895ZXCxW5wlEOU zEBSvo6FR+0/6Oy7hebkyigtXZCCdy5oS2+LRODyIM+82cEw293yle4NyfcbpifUnE8L tLHMd3hnqQFEWAeXdzSWIJVgwIxhwaNgURCXjAzSGwKYofsCyJ1NJrrxOCsdvHTnaZpm fvkcXC5C0OgIfEemb9dN3UrnKgCw8s57WXznKmtulgT90Hqlt+NgeWlL/IJewF+k+CX0 9OQKLnUdE/d9Ss3B1GtfCoSt57GNGGqkxhorHxgp9/HWRUHUWYemf5Z8DmWLPDtS5ikq mhbg== X-Received: by 10.70.129.72 with SMTP id nu8mr119026488pdb.72.1426519626737; Mon, 16 Mar 2015 08:27:06 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <87d249q8qs.fsf@elektro.pacujo.net> References: <5501be8b$0$13006$c3e8da3$5496439d@news.astraweb.com> <874mpnp6nv.fsf@elektro.pacujo.net> <87y4mznmj8.fsf@elektro.pacujo.net> <55062bda$0$12998$c3e8da3$5496439d@news.astraweb.com> <87egopmn4z.fsf@elektro.pacujo.net> <55069623$0$12901$c3e8da3$5496439d@news.astraweb.com> <87vbi1qg0t.fsf@elektro.pacujo.net> <7cf04117-0fd5-40fb-bcaf-351353afc68b@googlegroups.com> <5506dd28$0$12975$c3e8da3$5496439d@news.astraweb.com> <87d249q8qs.fsf@elektro.pacujo.net> From: Ian Kelly Date: Mon, 16 Mar 2015 09:26:26 -0600 Subject: Re: generator/coroutine terminology To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1426519629 news.xs4all.nl 2971 [2001:888:2000:d::a6]:44641 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87569 On Mon, Mar 16, 2015 at 9:09 AM, Marko Rauhamaa wrote: > Ian Kelly : > >> For generators, the descriptive keyword ("yield") could be buried >> *anywhere* in that block. One can glance at a generator function and >> fail to notice that it is a generator function. This is the one that >> really bugs me about reuse of "def", although you are correct that >> this is a case where practicality has won over purity. > > I don't think that's all that big of a deal even though I will readily > admit having stumbled on it early on. I removed the last "yield" > statement from a generator expecting it to keep on being a generator. > Thus, you have to do things like: > > def nothing(): > if False: > yield None > > The "pass" and "global" statements make me think it might be more > Pythonic to have separate syntax for the special case: > > def nothing(): > yield not My (limited) experience with asyncio is that it also makes this a bit worse. I write a function intended to be a coroutine invoked from coroutines using "yield from", and then I realize that it's not a coroutine because it never uses "yield from" itself. Or inversely I write a normal utility function that is called from coroutines, then later add a "yield from" to it, and now I have to go back and revise every place where it's called to make those use "yield from" as well.