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

Ian Kelly ian.g.kelly at gmail.com
Mon Mar 24 18:24:00 CET 2014

On Mon, Mar 24, 2014 at 3:55 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Ian Kelly <ian.g.kelly at gmail.com>:
>> If lambda were going to be deprecated and removed then it already
>> would have happened in Python 3, because Guido tried to do precisely
>> that. I'm not sure what the reasons were for keeping it in the end
>> (according to PEP 3099 it was because nobody suggested a suitable
>> replacement), but if he couldn't get rid of it then, he never will.
> You never *need* (Python's) lambda for anything. Inner functions are
> more capable and almost always more readable. It doesn't hurt to have
> lambda, but I don't find any use for it, either.

So what? One might say the same thing about comprehensions -- loops
are more capable and almost always more readable.

More information about the Python-list mailing list