Explanation of this Python language feature? [x for x in x for x in x] (to flatten a nested list)

Mark H Harris harrismh777 at gmail.com
Mon Mar 24 19:58:16 CET 2014

On 3/24/14 4:58 AM, Mark Lawrence wrote:
> Where do you get reduce from if it's not in the standard library?

    That was "a" proposal for 3000. Its there, but its not on the 
built-ins; ie., you have to import it.  The confusion: why reduce, why 
not filter, nor map?  {rhetorical}

> As for lambda I've no real interest in it, other than when copying examples
> where it's used to (say) provide a key function.

This is one of my main points to Steven. In my experience "most" people 
do not intend to use lambda for anything; they are trying to sort this 
or that and don't quite know how to get the key right and some helpful 
somebody gives them a key=lambda yadda yadda .  They use it, and it 
works, but they are scratching their head saying to themselves, "what it 
that, how does it work, how can I understand it and on and on".

That is what we mean by confusing. Or another really great example is 
this thread. Somebody asks about a language feature and somebody else 
helpfully answers the question by providing them with a similar lambda!!

Its the programmer's equivalent of explanation by reference to a more 
complicated analogy; which leaves the OP left with, "Thanks for all the 


PS  You are absolutely right, all the expanding double spaces become 
very annoying when viewed on Thunderbird; it is exasperating, genuinely.

More information about the Python-list mailing list