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
Thu Apr 3 12:38:13 EDT 2014


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. 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 didn't ask when it was introduced, I asked when it became useful?
>
> It was useful immediately when introduced. Do you really think we would
> add something useless, and that no one wanted to use?  Core developers
> constantly ask 'What is the practical use case?' in response to
> suggested additions.

    'Useful' must always be taken in context, and also contextually 
evaluated with an on-going methodology which constantly informs 
'usefulness' on a continuum. I admire and encourage the core devs, in 
their pursuit of excellence. Asking 'what is the practical use case?' is 
essential. Not always is the answer complete.
    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 ) The commitment and dedicated effort to move 
forward with a unicode default is not only commendable, but also admits 
to the 'usefulness' of same. Its not that version 2 was useless, its 
just that version 3 is so much more useful that people are 'using' it 
and dedicating their resources moving forward with python3.
    This is similar to the decimal module. Of course it had limited 
usefulness in version(2) thru 3.2/  but now, python3.3+ the decimal 
module is truly useful! Why? Glad you asked... because it is now fast 
enough for use cases previously reserved for floats. I found limited 
usefulness for decimal prior to 3.3, but now we're finding decimal so 
useful that some of us are wanting decimal to be the default. ( all of 
this is also relative and debatable )

> Fine. You asked 'When did unicode in Python become useful.'
> Answer: 2.0, not 3.0. Most unicode use in Python is still running on
> Python 2. It works well enough that people are reluctant to migrate
> working and tested production code. End of discussion?

    Sure. Yes, this is sad. Python2 works. Python2 is inconsistent, and 
troublesome. ( I do not mean that to be insulting, not in the least, its 
just true )
    I've been studying python3 now for several years; cross referencing 
between python2 and python3 has been fun and illuminating, from a 
practical programming standpoint as well as from a standpoint of general 
interest in computer science, and the science of language design. Its 
been a magnificent journey for me (thanks to all of you who provided the 
food for thought, as it were )
    Python3 is not perfect; but python3 is *way* more consistent than 
python2 and consequently *way* more useful than python2. ( this is 
relative, debatable, or even certainly one of those discussions of 
personal preference and taste perhaps ) As we move forward with use 
cases we grow and consequently our language evolves. This is true of the 
spoken word, also true of the comp sci word. In this sense, at this 
time, I would call python2 a 'mess'. Python3 straightened up the 'mess' 
pep after pep.  At what point does do we arrive at 'elegant'?  Beats me.
Maybe when number is unified, decimal is default, scientists are free to 
mix literals of all types in a convenient and intelligent way. But, for 
the moment, python3 is elegant---and very useful.  No doubt Python4 will 
build upon that; perhaps we will come to think of python3 as a mess?

> I hear, speak, read, and write standard American English.
>

    ~nice.   Trouble is, as we've stated before, most of our comm in 
life is non verbal.  So, even in the best (E)scale effectiveness we are 
at a loss because mailing lists and news servers lose the non verbals, 
the smiles, and shrugs, the waves, and the handshakes. rats()

Enjoy your day Terry.


PS   I just thought of another example along the lines of continual 
usefulness: IDLE. (you've worked on IDLE, right?) IDLE is now useful ! 
---a few years back, not so much.  That is not to say that IDLE was 
*never* useful back in the day (it always has been, to some extent), but 
since it has matured over the years it is at a point now where it really 
can be the default (very useful) development interface for code and 
test. Its now stable, does what it advertises, and provides a clean 
simple environment that is pleasant to work with. I ask nay-Sayers, 
"Have you driven an IDLE lately?"




More information about the Python-list mailing list