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

MRAB python at mrabarnett.plus.com
Mon Apr 7 21:52:37 EDT 2014


On 2014-04-08 02:33, Mark H Harris wrote:
> On 4/6/14 12:31 PM, Rustom Mody wrote:
>
>> I think python wins because it (usually) lets people do their thing
>> (includes but not limited to CS-research)
>> and gets out of the way.  To say therefore that it is irrelevant to the
>> research is a strange inversion of its advantages.
>
>      I think so too. I find python useful for modeling (prototyping)
> constructs that it [python interpreter] was not 'designed' to do.
>
>> [Or simply just switch to C++ for 3 months and report back with
>> the increment in your white-hair-count]
>
>      Back in the day I used Rexx to prototype a new language idea, or a
> new computational technique. Today I use python for prototyping.
>
>      From a CS standpoint I can use python for research in morphology
> because of the flexibility and extensibility of the namespace, and the
> easy ability to create new nouns and verbs through 'def' (as either
> function or generator) and the iterative process over data types like
> 'list' and 'dict'. I am playing with neural nets again, using python,
> and liking the fact that I can put my ideas into practice easily and
> python gets out of the way. I find it a great research language. I am
> surprised that others only see it as a problem solving tool.
>
>
>      I have another question for y'all, is a function (particularly a
> generator) a noun or a verb?  Does a function (or generator) 'do'
> something (based on name and parms) or does it 'return' something based
> on name and parms? Based on name and parms should a function (or
> generator) function as a noun, or function as a verb, or *both*? --or,
> are Classes nouns only, and all functions *are* verbs only?
>
A function is an object (noun) that does stuff (verb).

Does that make it clearer? :-)



More information about the Python-list mailing list