Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'python.': 0.02; 'assuming': 0.09; 'function,': 0.09; 'shame': 0.09; 'translate': 0.10; 'python': 0.11; 'better:': 0.16; 'clunky': 0.16; 'finney': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'loops': 0.16; 'notation': 0.16; 'statement.': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'seems': 0.21; '>>>': 0.22; 'aug': 0.22; 'exists': 0.24; 'merge': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'towards': 0.31; '>>>>': 0.31; 'subject:end': 0.31; 'way?': 0.31; 'writes:': 0.31; 'regular': 0.32; 'quite': 0.32; 'fri,': 0.33; 'no,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'sequence': 0.36; 'doing': 0.36; 'possible': 0.36; 'list': 0.37; 'ben': 0.38; 'filter': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'expression': 0.60; 'course': 0.61; 'simple': 0.61; 'back': 0.62; 'kind': 0.63; 'map': 0.64; '30,': 0.65; 'charset:windows-1252': 0.65; '5:15': 0.84; 'pardon': 0.84; 'sometimes.': 0.84; 'lazy': 0.91; 'wanting': 0.93; 'incorporated': 0.95; '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:content-transfer-encoding; bh=/Hbw2N5qlZYVSTbi/u3L5b33u8VMOCNRUWy/oZ4tX+4=; b=ri8J1hcNLn3iy75uQ6k9hZDIqrH/aV0d2ZXeIsLrrFpMANWKABb6R7tdMYgYy10VXi vikYbM7kTJkE/YWnac0yriToY9EjyKgY4LskKEClOfwOP6JCoKKtT0ODh8dy0RjLOHzi 314iqHJZ5xjc+7aaN6FAnUnWqYlLbbrGvnRlpcLRJpHXAnpYjPJIqIheI09uHk6d4Ouh VGZ06G8jwSqmhR47VzzCYPq5Lpycl7MEXGNIXGIcysK/o3B4pgtw9ny1wFcy8YgFbdc2 tnsK9kJZQ1EzIbUk9yGyxPrDVcpLd94c55wUSaQND0IjAP5zKYlaPICmMK79CvbBOg9d WiKw== MIME-Version: 1.0 X-Received: by 10.58.218.225 with SMTP id pj1mr5095782vec.24.1377847538066; Fri, 30 Aug 2013 00:25:38 -0700 (PDT) In-Reply-To: <5220468E.4070407@rece.vub.ac.be> References: <1377735506.18906.15.camel@debian> <1FETt.52607$Mw4.14965@fx15.am4> <7wob8gywds.fsf@benfinney.id.au> <7wfvtrkcae.fsf@benfinney.id.au> <5220468E.4070407@rece.vub.ac.be> Date: Fri, 30 Aug 2013 17:25:37 +1000 Subject: Re: semicolon at end of python's statements From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1377847546 news.xs4all.nl 15993 [2001:888:2000:d::a6]:40458 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53283 On Fri, Aug 30, 2013 at 5:15 PM, Antoon Pardon wrote: > Op 30-08-13 06:55, Ben Finney schreef: >> Ben Finney writes: >> >>> F=E1bio Santos writes: >>> >>>> It is a shame that this is not possible in python. for..if exists in >>>> comprehensions and not in regular loops but that would be nice >>>> sometimes. >>> for foo in (spam for spam in sequence if predicate(spam)): =85 >> >> Better: >> >> for foo in filter(predicate, sequence): >> process(foo) > > Well better in what way? You now have to translate a predicate > expression into a predicate function. Which AFAIU was one of > the reasons to move away from map/filter to list comprehension. > > As I understand it, python made a move away from map and filter > towards list comprehension. Chris seems to want some of the > possibilities that came with that incorporated into the for > statement. And your suggestion is to go back to the old kind > of filter way. No, actually Ben's quite right - assuming the predicate is a simple function, of course (Python's lambda notation is a bit clunky for comparisons); as of Python 3, filter() is lazy and is pretty much what I'm doing here. However, that's still a specific answer to a specific (albeit common) instance of wanting to merge control structures. ChrisA