Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!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.071 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'explicitly': 0.05; '__init__': 0.09; 'generators': 0.09; 'def': 0.12; '(which,': 0.16; 'declaration': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'gained': 0.16; 'shortcut': 0.16; 'wrote:': 0.18; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'related': 0.29; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'coded': 0.31; 'class': 0.32; 'are:': 0.33; 'not.': 0.33; 'comment': 0.34; 'maybe': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'yield': 0.36; 'method': 0.36; 'subject:?': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'that,': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'ian': 0.60; 'most': 0.60; 'entire': 0.61; 'such': 0.63; 'different': 0.65; '30,': 0.65; 'needing': 0.65; 'determine': 0.67; 'benefit': 0.68; 'results': 0.69; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=3XO279Xo5RqmqVGmzeKrtD5YMCEPoFH68LcQs9ZT2lo=; b=XqVUU+GGI/AYHOyBGyclsKU/cv/63RdraIyjOOLK75LUuonwjTRX8wgZoGJOSxAcDT SwxvtSPsDvZ5ypBcZ8qu61Hr3lYOCnjck0z+YURz7HNuWpJFWxvWzGjRBlNohUCR7TtP ZwtnLQfBcL8bodaEPXMbctZNCpeZ2RZgXsyk/57IX3rRjpIXejoGudzfVvxAmSZhDtjx QEqZWclqUGqarYTtconCQxFdLhm21VTYkL95H4n8sbHgk3oY0pXm8WaIgo9vZOuLU1Nk lSsSA4fAIWJxCjBAw+n3rwxwdz4FwmlqAe2GnXA8hvB3J4BDyB2y60SH9hCUWuAgxCiv dROg== MIME-Version: 1.0 X-Received: by 10.220.48.17 with SMTP id p17mr7663509vcf.97.1372571961983; Sat, 29 Jun 2013 22:59:21 -0700 (PDT) In-Reply-To: References: <2a2072e3-4b12-4ada-872c-1240d2379928@googlegroups.com> <51cf2b49$0$29999$c3e8da3$5496439d@news.astraweb.com> <2f5e7801-a4cd-4d01-a1e7-7f67bca18199@googlegroups.com> <51cf3695$0$29999$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 30 Jun 2013 15:59:21 +1000 Subject: Re: Closures in leu of pointers? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1372571965 news.xs4all.nl 15912 [2001:888:2000:d::a6]:57864 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:49475 On Sun, Jun 30, 2013 at 3:46 PM, Ian Kelly wrote: > On a related note, I think that generator functions should in some way > be explicitly marked as such in the declaration, rather than needing > to scan the entire function body for a yield statement to determine > whether it's a generator or not. Most functions are: def func(args): body return result Generators are: class func(args): # okay, you can't shortcut it like that, give it an __init__ method def do_stuff(self): body yield results one by one I don't know that anything would be gained by having a different function declaration statement/attribute, but maybe this is something that would benefit from a code comment (which, as far as I'm concerned, is as much a part of the function signature as the coded parts are). ChrisA