Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'feedback.': 0.04; 'nested': 0.07; 'code"': 0.09; 'defines': 0.09; 'generators': 0.09; 'iterate': 0.09; 'tmp': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'appreciated!': 0.16; 'definitions,': 0.16; 'iterable': 0.16; 'iterator': 0.16; 'subject:generator': 0.16; 'think?': 0.16; 'basically': 0.19; 'passing': 0.19; 'seems': 0.21; 'example': 0.22; 'minutes.': 0.22; 'cc:addr:python.org': 0.22; 'skip': 0.24; 'cc:2**0': 0.24; 'source': 0.25; 'define': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'went': 0.31; '(since': 0.31; 'class': 0.32; 'probably': 0.32; 'everyone': 0.33; 'skip:_ 10': 0.34; 'maybe': 0.34; 'could': 0.34; 'something': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'next': 0.36; 'method': 0.36; 'useful': 0.36; 'thanks': 0.36; "i'll": 0.36; 'possible': 0.36; 'example,': 0.37; 'too': 0.37; 'clear': 0.37; 'feedback': 0.38; 'itself': 0.39; 'more': 0.64; 'levels': 0.65; 'to:addr:gmail.com': 0.65; 'yes': 0.68; '3-4': 0.68; 'audience': 0.74; '*how': 0.84; 'feedback,': 0.84; 'convinced': 0.93 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 :cc:content-type; bh=M/AwVdftM9WzKNt6A22lqTuuFgDDEfz3ZFlxAibNX1Y=; b=U/uIBsHzYaXXMQxvYLSDiN4HZGWTei2k66+Qcdi/h3A5CloxmeTfJi62MyY09w+re1 VF5VxrAmYgoGE3XRESjVHHPaxPe0z16HUXU2ArHfaPHVFsow45SBES9+thLEWvAdBlyG EKMw9yDzKTG1AeGAXSmlhVVPmvbjmskFtJ2pihpLr6bkUnRJzS5plsX5dTJ7vFjM7t5u ujXElwgXX8jneHv97jowrAlzpOHMXcczAcBA1hgXNwYWFyXpoJmkbGQG41UUYxwidH5g g3iv0fcsOgRryEpTYWVKKnxvr0uezGDk04pQ7Xbr17VT974n+NSr0m2j1ZBBy44WttU9 eauQ== MIME-Version: 1.0 X-Received: by 10.52.110.201 with SMTP id ic9mr21868407vdb.22.1391381759097; Sun, 02 Feb 2014 14:55:59 -0800 (PST) In-Reply-To: References: <8118b17c-3352-4832-8567-089bd14c21ce@googlegroups.com> Date: Sun, 2 Feb 2014 22:55:59 +0000 Subject: Re: generator slides review From: andrea crotti To: Miki Tebeka Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391381767 news.xs4all.nl 2978 [2001:888:2000:d::a6]:43125 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65290 Thanks everyone for your feedback. The talk I think went well, maybe I was too fast because I only used 21 minutes. >From the audience feedback, there were some questions about my "Buggy code" example, so yes probably it's not a good example since it's too artificial. I'll have to find something more useful about that or just skip this maybe. For possible generators drawbacks though I could add maintanability, if you start passing generators around in 3-4 nested levels finding out what is the original source of can be difficult. I'm also still not convinced by the definitions, which I tried now to make clear and ay something like: - and iterator defines *how you iterate* over an object (with the __next__ method) - an iterable defines *if you can iterate* over an object (with the __iter__ method) And when I do something like this: class GenIterable: def __init__(self, start=0): self.even = start if is_even(start) else start + 1 def __iter__(self): return self def __next__(self): tmp = self.even self.even += 2 return tmp it basically means that the a GenIterable object is iterable (because of __iter__) and the way you iterate over it is to call the next method on the object itself (since we return self and we define __next__). That seems clear enough, what do you think? I might give this talk again so feedback is still appreciated!