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

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Apr 4 05:53:31 EDT 2014


On Thu, 03 Apr 2014 11:38:13 -0500, Mark H Harris wrote:

> On 4/1/14 5:33 PM, Terry Reedy wrote:
> 
>     hi Terry, hope you are well today, despite gmane difficulties;
> 
>> If you narrowly meant "The python interpreter only starting using
>> unicode as the default text class in 3.0", then you are, in that narrow
>> sense, correct.
> 
>     Yes. When I speak of 'python' I am almost always speaking about the
> interpreter.

Which interpreter? PyPy, Numba, Nuitka, or perhaps even the newest in the 
family, Pyston?

https://tech.dropbox.com/2014/04/introducing-pyston-an-upcoming-jit-based-
python-implementation/

Wait, all of those are compilers! Nuitka is a static compiler, the others 
are JIT compilers. Perhaps you meant Jython, IronPython, or Stackless? 
They're all interpreters.

Ah, they're compilers too! Specifically, byte-code compilers. There's 
even a compile() built-in function.

I'm not just being pedantic for the sake of being annoying[1], there's an 
important point here. Namely, that we shouldn't conflate Python the 
language with any one specific compiler or interpreter. Not even -- 
*especially* not even -- CPython the reference implementation.

So we have Python *the language*, and any of a number of implementations. 
By my count, including experimental, obsolete and abandoned versions, I 
know of at least 50 different implementations, at least 10 of which might 
count as "the Python interpreter" for somebody. So the question is, when 
you speak of "Python", do you mean *a specific implementation*, or do you 
mean *the language*?



> If I speak of the python community, and I rarely do, I
> explicitly use the word 'community'. I am concerned with backward
> compatibility in my own stuff, but I am primarily interested in python3,
> and I have made the conscious decision to use only python3 moving
> forward, except in those cases (like QPython 2.7.2 on the Android
> platform ). So, python(3)'s use of unicode is exciting, not only as a
> step forward for the python interpreter, but also as a leadership step
> forward in computer science around the world.

I appreciate your enthusiasm, but let's not get too excited. Python is 
neither the first, nor the most influential, language to include Unicode. 
And as for it being a "leadership" step in computer science, that's 
rather like me proclaiming that my local take-away Italian restaurant 
shifting to gluten-free pasta is a revolution in chemistry.

Python is not a computer-science-ey language. It is of little or no 
interest to computer scientists involved in the mathematics of 
computation, or compiler-theory, or type-theory, or any of the other 
academic disciplines under comp-sci. It's true that you might get a 
semester or two of learning Python in a comp-sci course (but more likely 
to be Java), but that's only because students have to be taught 
*something*. Comp-sci researchers are far more likely to be using 
something like Mercury or Haskell, not Python.

Unicode is completely uninteresting to comp-sci. Whether strings contain 
127 symbols or 1114112 or 2 is just a boring detail.


[...]
>     On the python unicode continuum version (3) is more useful than
> version (2). ( this is of course relative and debatable, so the
> statement is rhetorical ) 


Now that's funny. You make a completely non-controversial statement, that 
Python 3's Unicode implementation is more useful (i.e. more functionally 
complete, fewer design flaws, more efficient) than Python 2's, and *that* 
is the claim that you smother to death in disclaimers. Whereas other 
statements you make, which sometimes have been as wrong as an utterly 
wrong thing, you've been prepared to go to the battlements and fight to 
the death over.




[1] Although that's a bonus *wink*


-- 
Steven D'Aprano
http://import-that.dreamwidth.org/



More information about the Python-list mailing list