Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'elements.': 0.07; '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; 'true:': 0.16; '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; 'except': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'yield': 0.36; 'thanks': 0.36; 'should': 0.36; 'clear': 0.37; 'thank': 0.38; 'filter': 0.38; 'changed': 0.39; 'number,': 0.60; 'break': 0.61; 'more': 0.64; 'to:addr:gmail.com': 0.65; '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=vh899T9vMm+xhlT4AVTQESvyHXJ3aJBzpjB3b3YT8Yw=; b=P9rF4XgatM0gfxLXrKc1653EuFQkWyLERrvgTksncXK63ALL8XCTtJKN5nJGWxnQ5+ N5qkWACUcvASUHpYKHnGBHuEk3MkV1rrEBipzK7jSXyOt+2GDDO830NjqPmkqFkJ6QeW BPqs0gYqoI5NxzdrNYtZw4zGcgwJmDkqF5dPXmX44jddwlM6JjY5pPtW0GvRAzswchPE 9G4N+zVf2Tw7Jmz8vVCaVXZhyBc2VWwdj2u/gKwjMTbjGQpwAotX6GMo87F+Iyd7NV2n fCNX3VrgX8h78PTdXTW/lZGRjyRg4Wylb1yoFzS++9gaj4rp58Ezmfzom9wety09O0yU xLSA== MIME-Version: 1.0 X-Received: by 10.52.181.33 with SMTP id dt1mr20593768vdc.21.1391338244574; Sun, 02 Feb 2014 02:50:44 -0800 (PST) In-Reply-To: References: <8118b17c-3352-4832-8567-089bd14c21ce@googlegroups.com> Date: Sun, 2 Feb 2014 10:50:44 +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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391338252 news.xs4all.nl 2886 [2001:888:2000:d::a6]:57962 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65258 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).