Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2a.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.034 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.06; 'function,': 0.09; 'subject:language': 0.09; 'url:activestate': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; ':-p': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'magic': 0.16; 'subject: \n ': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'example.': 0.24; 'looks': 0.24; 'cc:2**0': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'url:code': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'that.': 0.31; '25,': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'received:google.com': 0.35; 'method': 0.36; 'mine': 0.38; 'helps': 0.61; "you'll": 0.62; 'hear': 0.63; 'more': 0.64; 'talking': 0.65; 'mar': 0.68; 'funny': 0.74; 'subject:this': 0.83; 'to:none': 0.92; 'wait,': 0.93; 'serious': 0.97 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=fQaGdVc/fXlj40XvKSf2+CD1xStlA/jSTeOrIMBeKTU=; b=zoMXUN29G9tLgjFkQXq67eUmKe11VJwvQxFfXo6jIpwkfo/uQvzGrRj89boglsnHdZ 0VAXFGZdUEDOuyfgfDZDSGeTuIm+44ZIzxgums46vdaRuN4iVlzX94WgvOC85WQ5R9PY hB5EbVTJTUX7FcSofl4ZKsfHpihzIS0TdFo69HMqmq1Y0NjFNKzb+JJmfg5/BDavEOHQ MxluAbkn4sXR6tdNA0Aco/zlHM0FZMN60bY/FyTFRz7m48CGPd5oO3VPg5IU+FWO1XGi f4+zhVWnq9GlFfEBEd/bncnB5DUQa89czBj2mXne7umF6YcQggjTV8S5CoxK+iF4Tp+R okiA== MIME-Version: 1.0 X-Received: by 10.66.102.39 with SMTP id fl7mr73071303pab.43.1395702422114; Mon, 24 Mar 2014 16:07:02 -0700 (PDT) In-Reply-To: <5330b88b$0$29994$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> <5330b88b$0$29994$c3e8da3$5496439d@news.astraweb.com> Date: Tue, 25 Mar 2014 10:07:01 +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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395702432 news.xs4all.nl 2933 [2001:888:2000:d::a6]:59484 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68911 On Tue, Mar 25, 2014 at 9:58 AM, Steven D'Aprano wrote: > On Tue, 25 Mar 2014 06:22:28 +1100, Chris Angelico wrote: > >> Aside: You'll often hear people talking about "map-reduce" with big >> data. Python supports that. Look! >> >>>>> map.__reduce__ >> >> >> Oh wait, that's nothing to do with reduce()... >> >> *ducks for cover* > > Ha ha, very funny :-P > > > http://code.activestate.com/recipes/577676-dirt-simple-mapreduce/ That looks like a more serious map/reduce example. Mine came from a double-take when I was looking at help(map) for some reason; there's a __round__ magic method that helps define the round() function, there's __abs__ for abs(), there's __str__ for str()... look, there's a __reduce__ - it must be to help define reduce()! :) ChrisA