Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'assignment': 0.07; 'incompatible': 0.07; 'coding:': 0.09; 'compact': 0.09; 'subject:language': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"by': 0.16; '"to': 0.16; '*only*': 0.16; 'ah,': 0.16; 'assignment.': 0.16; 'assignment?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'notation': 0.16; 'notations': 0.16; 'optional.': 0.16; 'other,': 0.16; 'reasonably': 0.16; 'should.': 0.16; 'subject: \n ': 0.16; 'demonstrate': 0.16; 'followed': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'all,': 0.19; 'stack': 0.19; 'meant': 0.20; 'cc:addr:python.org': 0.22; 'certainly': 0.24; 'convenient': 0.24; 'header': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '"do': 0.31; '25,': 0.31; "d'aprano": 0.31; 'factor': 0.31; 'steven': 0.31; 'symbolic': 0.31; 'languages': 0.32; 'quite': 0.32; 'entirely': 0.33; 'not.': 0.33; 'programmers': 0.33; 'basic': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'combination': 0.36; 'level': 0.37; 'expected': 0.38; 'others.': 0.38; 'pm,': 0.38; 'extremely': 0.39; 'sure': 0.39; 'either': 0.39; 'course': 0.61; 'simple': 0.61; 'offer': 0.62; 'high': 0.63; 'such': 0.63; 'more': 0.64; 'talking': 0.65; 'mar': 0.68; 'frequently': 0.68; 'forth': 0.81; 'subject:this': 0.83; 'iterative': 0.84; 'nicely.': 0.84; 'whereby': 0.84; 'convenience,': 0.91; 'sorry.': 0.91; 'to:none': 0.92; '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:date:message-id:subject:from:cc :content-type; bh=XAskLeL+nyLyp5SkTvI1qbB113ADqp1LqqKuP/GTeow=; b=iN7cYwyzaoYugn/PS5K94AmDy1axAxu9H1Up2PR60aR/DrG+qK+JkB0FgzjEELM0w+ 9jrSjizGzNrxLr8tHScq9222k2oAsOMZW4nJiCQ6BkrjkolZpO7A2+AngwZi3d/utzQF 22r/kVPljyPQJAhsQTFcxqalls08cUiUaJZHycPvNiGcUrWR4oOcNoqBoxXrFYpKv5JS VtBE6RWOvjmVrnbm1h3Pa4BmbbCnfJ+Y+8cjC7a9YUMUI0zAws4zf6snJfrk8fvKVj7S iGc1wRZqciLuhNCKxLhAsrAOEhEsXh6k5Tw7vuLu3z00ErwBMooVur5Xtjj+ArU+xoMY PE+Q== MIME-Version: 1.0 X-Received: by 10.68.200.74 with SMTP id jq10mr1094968pbc.169.1395726221164; Mon, 24 Mar 2014 22:43:41 -0700 (PDT) In-Reply-To: <533113fd$0$29878$c3e8da3$5496439d@news.astraweb.com> 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> <533113fd$0$29878$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 25 Mar 2014 16:43:40 +1100 Subject: Re: Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list) From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395726224 news.xs4all.nl 2871 [2001:888:2000:d::a6]:46972 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68965 On Tue, Mar 25, 2014 at 4:28 PM, Steven D'Aprano wrote: > On Tue, 25 Mar 2014 06:57:19 +1100, Chris Angelico wrote: > >> Can you imagine a high level language without a simple notation for >> variable assignment? Certainly not. > > I don't know... what a stack based or concatenative language like Forth, > Postscript, Joy or Factor count as high-level? > > I'm pretty sure Joy and Factor should. Perhaps not Forth or Postscript. > > Some of these language may offer variable assignment, but using it is > entirely optional. It's a convenience, nothing more. Ah, sorry. I meant in languages that do have a concept of variable assignment. Yes, some don't have it at all, so of course they don't offer any notation for it. But any reasonably modern symbolic language is not going to have a long and wordy notation for assignment, because assignment is so common. It's language design Huffman coding: the features programmers are expected to use frequently are given convenient notations. A stack-based language will have extremely convenient notations for "push this onto the stack", something like "Put potatoes into the mixing bowl. Put dijon mustard into the mixing bowl. Put lard into the mixing bowl." (okay, so Chef might not be the best language to demonstrate this with!). A basic iterative for loop is considered extremely common. C has a highly compact notation that packs three parts into a simple header; REXX has a more piece-meal approach whereby "DO I=start" can be followed by any combination of "TO stop", "BY step", "WHILE condition", "UNTIL condition", and "FOR count", each of which has the same effect on its own or in combination with others. (I think WHILE and UNTIL might be incompatible with each other, but none of the others conflict. Having TO and FOR in the same loop header means it'll stop when either condition is reached.) And Python doesn't have any such construct, but *only* a 'foreach'. That's what I was talking about; and yet it works quite nicely. ChrisA