Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'chunk': 0.07; 'python': 0.09; 'modules.': 0.09; 'pep': 0.09; 'cc:addr:python-list': 0.10; 'subject:python': 0.11; 'steve': 0.13; 'folks': 0.15; '1:09': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'inaccessible': 0.16; 'itertools': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:edu.au': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'simpson': 0.16; 'wrote:': 0.17; 'version.': 0.17; 'thanks,': 0.18; "i'd": 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'paul': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'am,': 0.27; 'paul.': 0.29; 'writes:': 0.29; 'version,': 0.30; 'code': 0.31; "who's": 0.32; 'certain': 0.33; 'goes': 0.33; '11,': 0.33; 'his/her': 0.33; 'version:': 0.33; 'version': 0.34; 'wrong': 0.34; 'nov': 0.35; 'too.': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'depends': 0.36; 'received:au': 0.36; 'ok,': 0.37; 'why': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'nothing': 0.38; 'skip:" 10': 0.40; 'think': 0.40; 'content-disposition:inline': 0.60; 'skip:u 10': 0.60; 'times': 0.63; 'to:addr:yahoo.com': 0.80; 'alternative.': 0.84; 'cheek,': 0.84; 'expressive': 0.84; 'itertools,': 0.84; 'metaphor': 0.84; 'otten': 0.84; 'quiz': 0.84; 'succession': 0.84; 'power,': 0.91 Date: Mon, 12 Nov 2012 11:43:56 +1100 From: Cameron Simpson To: Steve Howell Subject: Re: A gnarly little python loop MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3b0b8e3b-6f0a-4337-89ab-235e938952b2@y5g2000pbi.googlegroups.com> User-Agent: Mutt/1.5.21 (2010-09-15) References: <3b0b8e3b-6f0a-4337-89ab-235e938952b2@y5g2000pbi.googlegroups.com> Cc: python-list@python.org 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1352681039 news.xs4all.nl 6892 [2001:888:2000:d::a6]:39850 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:33156 On 11Nov2012 11:16, Steve Howell wrote: | On Nov 11, 10:34 am, Peter Otten <__pete...@web.de> wrote: | > Steve Howell wrote: | > > On Nov 11, 1:09 am, Paul Rubin wrote: | > >> Cameron Simpson writes: | > >> > | I'd prefer the original code ten times over this inaccessible beast. | > >> > Me too. | > | > >> Me, I like the itertools version better.  There's one chunk of data | > >> that goes through a succession of transforms each of which | > >> is very straightforward. | > | > > Thanks, Paul. | > | > > Even though I supplied the "inaccessible" itertools version, I can | > > understand why folks find it inaccessible.  As I said to the OP, there | > > was nothing wrong with the original imperative approach; I was simply | > > providing an alternative. | > | > > It took me a while to appreciate itertools, but the metaphor that | > > resonates with me is a Unix pipeline. [...] | > Actually you supplied the "accessible" itertools version. For reference, | > here's the inaccessible version: [...] | I know Peter's version is tongue in cheek, but I do think that it has | a certain expressive power, and it highlights three mind-expanding | Python modules. | Here's a re-flattened take on Peter's version ("Flat is better than | nested." -- PEP 20): [...] Ok, who's going to quiz the OP on his/her uptake of these techniques... -- Cameron Simpson It's hard to make a man understand something when his livelihood depends on him not understanding it. - Upton Sinclair