Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'elements.': 0.07; 'fixes': 0.07; 'things,': 0.09; 'try:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'count,': 0.16; 'itertools': 0.16; 'lambda': 0.16; 'subject:generator': 0.16; 'suggested,': 0.16; 'true:': 0.16; 'url:talks': 0.16; '>>>': 0.22; 'example': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'fine': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'message-id:@mail.gmail.com': 0.30; 'updated': 0.34; 'problem': 0.35; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'everyone.': 0.36; 'yield': 0.36; 'thanks': 0.36; 'should': 0.36; 'too': 0.37; 'clear': 0.37; 'thank': 0.38; 'filter': 0.38; 'explain': 0.39; 'changed': 0.39; 'enough': 0.39; 'easy': 0.60; 'number,': 0.60; 'tell': 0.60; 'break': 0.61; 'url:u': 0.61; 'url:index': 0.63; 'story': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'biggest': 0.67; 'andrea': 0.84 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=XWFTXxobWimdyZMBBvw5ZLKSsWGGCdhGHJPsUEqez7o=; b=b/haxULDF8xmbhKmGoodn9liy7L5kUp7IyUHJfk+nYRgMQ5/6l4l/qkTeMvuaTfizd FIBBjfbl6YHmOwZ5T7hCIQhIpTEcykO0C/ZoHpojrQPPuZBiLbvr3Xx8uIskqYSM+T5O 1h+3+U5jBeKn0LKmQU+7YdPwceA5pU+m+98HFqJytvrz3qWpykv6Oe26Ce7t2j4u0hlC 6P3tCNImXsRO3HP73QfKmluv0r2sMMHE35eRxEdCZD7WRS6FZSjz9sW8VT/7a51iiBxk ijrKkpJwuUqMXgc521esVvoPVZkByt3ktl6ONXwzaCsBpMBe/bU6AhnXTbENUTHtoSjN P72g== MIME-Version: 1.0 X-Received: by 10.58.66.137 with SMTP id f9mr24168944vet.11.1391338346070; Sun, 02 Feb 2014 02:52:26 -0800 (PST) In-Reply-To: References: <8118b17c-3352-4832-8567-089bd14c21ce@googlegroups.com> Date: Sun, 2 Feb 2014 10:52:26 +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: 53 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391338354 news.xs4all.nl 2942 [2001:888:2000:d::a6]:60115 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65259 Sorry left too early, the slides are updated with the fixes suggested, thanks everyone. https://dl.dropboxusercontent.com/u/3183120/talks/generators/index.html#1 For me the biggest problem is still: - to find some more interesting example that is easy enough to explain - to find a better order in which explain things, to tell a clear story in a way 2014-02-02 andrea crotti : > The slides are updated now > > 2014-02-02 andrea crotti : >> 2014-02-01 Miki Tebeka : >>> >>> My 2 cents: >>> >>> slide 4: >>> [i*2 for i in range(10)] >>> >> >> Well this is not correct in theory because the end should be the max >> number, not the number of elements. >> So it should be >> [i*2 for i in range(10/2)] which might be fine but it's not really >> more clear imho.. >> >>> slide 9: >>> while True: >>> try: >>> it = next(g) >>> body(it) >>> except StopIteration: >>> break >>> >> >> Changed it thanks >> >>> slide 21: >>> from itertools import count, ifilterfalse >>> >>> def divided_by(p): >>> return lambda n: n % p == 0 >>> >>> def primes(): >>> nums = count(2) >>> while True: >>> p = next(nums) >>> yield p >>> nums = ifilterfalse(divided_by(p), nums) >>> >> >> Thank you that's nicer, but ifiilterfalse is not in Python 3 (could >> use filter of course).