Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3a.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python,': 0.02; 'subject:Python': 0.06; 'modified': 0.07; 'subject:language': 0.09; 'language.': 0.14; '(int': 0.16; '24,': 0.16; 'iterating': 0.16; 'mean,': 0.16; 'subject: \n ': 0.16; 'syntactic': 0.16; 'utterly': 0.16; 'language': 0.16; 'wrote:': 0.18; 'filtering': 0.24; 'mon,': 0.24; "i've": 0.25; 'equivalent': 0.26; 'header:In- Reply-To:1': 0.27; 'chris': 0.29; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; '"do': 0.31; '(maybe': 0.31; 'basic': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'though,': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'even': 0.60; 'situation': 0.65; 'mar': 0.68; 'miss': 0.74; 'subject:this': 0.83; 'imagine': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=3i9YMFSp+ib0JBqV6R2L/EQu7pRp3IZBeo+bE6zxnBw=; b=u79YCoGfcwBNqXDjWy3toI1QWDBO9j6lU/fwvYaxCx54tBwlsPMF+UlzQ2GWWauIwR Q6eLYI9IvdD5Ec/5ntolw7caxTTaxkY1hDHxwyUQRuC97b3cfQVlw3WfoH+8d0NRPmut tvg1EX7luR7RXreJoY0eYjgTOxsgKGsDDqzZeUrNTa/HJ4vGucNTMK63mszWEhYdOSme uUPW8AILE0W7J3GYbwqznNxDk3/hG2niSrKkGd0YSfiTCd1wTYdT5oigX0QVDY0Xeow8 7L9zEr/rLG65HHeBiAqpchumfGHJWFBsWyuFkxfMiOsP60Gdq3bz6X4Ig7o3YX5S01hX czAw== X-Received: by 10.66.5.135 with SMTP id s7mr5193887pas.154.1395690164326; Mon, 24 Mar 2014 12:42:44 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <9daf0806-02de-4447-964c-c8f8953c23e5@googlegroups.com> <10101874-2995-4acd-9851-989603f052e3@googlegroups.com> <532d5bd9$0$29994$c3e8da3$5496439d@news.astraweb.com> <87bnwv2a5v.fsf@elektro.pacujo.net> <53303b8a$0$29994$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Mon, 24 Mar 2014 13:42:03 -0600 Subject: Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list) To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395690172 news.xs4all.nl 2837 [2001:888:2000:d::a6]:33575 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68897 On Mon, Mar 24, 2014 at 1:12 PM, Chris Angelico wrote: > Incidentally, I've often modified my loop counter, in C or REXX or any > other language. About the only situation where I actually miss it in > Python, though, is iterating over a list and mutating the list on the > way through; and even that can often be done in other ways (maybe a > list comp, filtering out some of the elements?). It's amazing how > something can be so utterly fundamental (I mean, come ON! Who can > imagine a language with no equivalent of the basic "do i=1 to 10" > (REXX) or "for (int i=0;i<10;++i)" (C++) loop???) and yet so > dispensable. I'm not sure "fundamental" is the right word. A for loop is just a while loop with some syntactic sugar. For that matter, a while loop is just a structured goto...