On Tue, Feb 27, 2018 at 11:46 PM, Matt Arcidy <marcidy@gmail.com> wrote:
From readability, the examples put forth have been to explain the advantage, with which I agree.  However, i do not believe this scales well.

[(foo(x,y) as g)*(bar(y) as i) + g*foo(x,a) +baz(g,i) for x... for y...]

This definitely looks hard to read.  Let's compare it to:

lst = []
for x in something:
    for y in other_thing:
        g = f(x, y)
        i = bar(y)
        lst.append(g*foo(x,a) + baz(g,i))

Obviously the one-liner is shorter, but the full loop looks a heck of a lot more readable to me.

I was thinking of an example closer to the PEP like this:

[((my_object.calculate_the_quantity(quant1, vect2, arr3) as x), log(x)) for quant1 in quants]

Just one "as" clause, but a long enough expression I wouldn't want to repeat it.  I still feel this suffers in readability compared to the existing option of (even as a non-unrolled comprehension):

[(x, log(x)) for x in (my_object.calculate_the_quantity(quant1, vect2, arr3) for quant1 in quants)]


Sure, again we save a couple characters under the PEP, but readability feels harmed not helped.  And most likely this is another thing better spelled as a regular loop.
 
--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.