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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'languages,': 0.04; 'interpreter': 0.05; 'mathematics': 0.05; 'subject:Python': 0.06; '(especially': 0.07; 'compiler': 0.07; 'elements.': 0.07; 'purpose.': 0.07; 'referring': 0.07; 'arguments': 0.09; 'arguments,': 0.09; 'executed': 0.09; 'executes': 0.09; 'implemented.': 0.09; 'lines.': 0.09; 'logic': 0.09; 'method,': 0.09; 'occasionally': 0.09; 'oop': 0.09; 'pretend': 0.09; 'python:': 0.09; 'subject:language': 0.09; 'useless': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'language.': 0.14; 'useful,': 0.14; "wouldn't": 0.14; 'aiming': 0.16; 'comp': 0.16; 'doing,': 0.16; 'eat': 0.16; 'eternal': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instantiated': 0.16; 'islands': 0.16; 'lambda': 0.16; 'languages)': 0.16; 'latter,': 0.16; 'letting': 0.16; 'philosopher': 0.16; 'subject: \n ': 0.16; 'syntactic': 0.16; 'top-level': 0.16; 'utterly': 0.16; 'elements': 0.16; 'ignore': 0.16; 'so.': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'else,': 0.19; "hasn't": 0.19; 'normally': 0.19; 'examples': 0.20; 'programming': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'define': 0.26; 'certain': 0.27; 'skip:" 20': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; "doesn't": 0.30; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'apparently': 0.31; "d'aprano": 0.31; 'directly,': 0.31; 'steven': 0.31; 'though.': 0.31; 'languages': 0.32; 'stuff': 0.32; "can't": 0.35; 'agree': 0.35; 'something': 0.35; 'definition': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'earth': 0.36; 'method': 0.36; 'too': 0.37; 'depends': 0.38; 'e.g.': 0.38; 'anything': 0.39; 'functional': 0.39; 'unable': 0.39; 'either': 0.39; 'called': 0.40; 'even': 0.60; 'most': 0.60; 'tell': 0.60; 'mentioned': 0.61; 'simple': 0.61; 'hear': 0.63; 'real': 0.63; 'such': 0.63; 'more': 0.64; 'side': 0.67; 'between': 0.67; 'results': 0.69; 'surprise': 0.74; 'theoretical': 0.74; 'analysis': 0.75; 'truth': 0.81; 'you:': 0.81; 'subject:this': 0.83; 'avoids': 0.84; 'beats': 0.84; 'etc,': 0.84; "everything's": 0.84; 'female': 0.84; 'forks': 0.84; 'husbands': 0.84; 'island': 0.84; 'pike': 0.84; 'ruled': 0.84; 'study,': 0.84; 'zen': 0.84; 'afford': 0.91; 'same,': 0.91; 'to:none': 0.92; 'differences': 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=cp2qv/bphklf4TtI7/BZQzicr7o5Q7B328LIShXEIi0=; b=jrLkObki0JB7J1B3jpkB3ueD6jJrER5bypaoJdlwyYxHUQZmz3M2cgyGwRfA/3k2/7 A7iT8c4rAjMy49UUfQDIDsgohxyuzFOZ1mM+uyC/BwotkiCKlGPeNydRWDRN/ex8lK0F N+4/c21Q99+77Gij6Myc4p4OhHvVsQvprHanj5CksvveR6CPMbEEDi8pDdsMuPSpOdiG spThqzpnCa5X5zQgJgKXc1zyulYGrP4qQ6Qf9iEU+yU+mR6pCuShS7oEk4BpLCK7GWBB FunWJF+2JdSeu4/UfkUmSz3pLgTh0/TWkVr/oTT9v/PbiKC41NevgX6GfKpUcWdBe+8L bTWA== MIME-Version: 1.0 X-Received: by 10.68.170.131 with SMTP id am3mr17149572pbc.97.1396805276986; Sun, 06 Apr 2014 10:27:56 -0700 (PDT) In-Reply-To: <53418644$0$29993$c3e8da3$5496439d@news.astraweb.com> References: <9daf0806-02de-4447-964c-c8f8953c23e5@googlegroups.com> <5334c38e$0$29994$c3e8da3$5496439d@news.astraweb.com> <53364327$0$29994$c3e8da3$5496439d@news.astraweb.com> <53365F55.2040302@gmail.com> <533836c4$0$29994$c3e8da3$5496439d@news.astraweb.com> <533e811a$0$29993$c3e8da3$5496439d@news.astraweb.com> <874n26su9f.fsf@elektro.pacujo.net> <53418644$0$29993$c3e8da3$5496439d@news.astraweb.com> Date: Mon, 7 Apr 2014 03:27:56 +1000 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: 59 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396805656 news.xs4all.nl 2908 [2001:888:2000:d::a6]:55223 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69772 On Mon, Apr 7, 2014 at 2:52 AM, Steven D'Aprano wrote: > (4) This is the category which I was referring to when I said that Python > wasn't a "computer-science-ey language": do people use Python for > research into language-independent fundamental principles of computation? > I don't think so. I agree with Marko that normally you: > >> you either use a pseudolanguage or some sort of formalism that >> hasn't been implemented. > > E.g. most of the really deep stuff by Turing wasn't even performed on a > computer... A simple reason for that is summed up in the Zen of Python: Practicality beats purity. For a comp sci theoretical study, you want something that exemplifies purity. That's why you get examples like the ones mentioned below - a dining philosopher is fundamentally unable to do such a simple thing as look to see what his neighbours are doing, and is also apparently unable to think and eat at the same time (plus, why on earth can't they afford a few more forks in the interests of hygiene??!?). Defining all of mathematics in terms of lambda is wonderfully pure, and utterly useless for any practical purpose. It's the same, in my opinion, with the eternal arguments about functional vs imperative vs declarative programming languages, and with the differences between compilers and interpreters, and whether something's a second-generation or third-generation or fourth-generation language. You can define all those terms in nice pure ways ("a compiler translates code into something that can be executed directly, but an interpreter parses code bit by bit and executes it"), but most actually-usable systems blur the lines. I still haven't seen any real definition of FP or OOP (especially the latter, O!) that doesn't ultimately come down to "avoid these language features which violate FP/OOP principles", which means that most programming languages (and more so with popular languages) are neither and/or both. It's all very well to say that everything is a function whose return value depends solely on its arguments, but practicality demands that you allow side effects in certain places. And it's all very well to say that everything's an object and every bit of code is a method, but aiming too far for purity results in Java-like syntactic salt. Pike avoids this somewhat by letting you pretend that it's a C-like module with top-level functions, but actually it's instantiated an object and called a method on it. That's occasionally useful, but most of the time you just ignore it and work imperatively. Python goes a bit further: top-level is just code like anything else, and it gets executed straight down the line. Practicality beats purity. >> * unfaithful husbands on an island ruled by female logicians > > I don't know that one. Me neither, although I can see elements of classic logic analysis elements. Islands ruled by logicians, people who always tell the truth / always tell exact falsehoods, etc, etc. I don't know of any that involve unfaithful husbands, but it wouldn't surprise me. Would like to hear it though. ChrisA