On Mon, Oct 17, 2016 at 9:11 AM, Random832 wrote:
Once again, this alleged simplicity relies on the chosen example "x for
x" rather than "f(x) for x" - this one doesn't even put the use of
flatten in the right place to be generalized to the more complex cases.
You'd need list(flatten(f(x) for x in iterable))

What you're saying is EXACTLY 180 deg reversed from the truth.  It's *precisely* because it doesn't need the extra complication that `flatten()` is more flexible and powerful.  I have no idea what your example is meant to do, but the actual correspondence is:

[f(x) for x in flatten(it)]

Under my proposed "more flexible recursion levels" idea, it could even be:

[f(x) for x in flatten(it, levels=3)]

There would simply be NO WAY to get that out of the * comprehension syntax at all.  But a decent flatten() function gets all the flexibility.

Honestly, it goes beyond just being "wrong". The repeated refusal to
even acknowledge any equivalence between [...x... for x in [a, b, c]]
and [...a..., ...b..., ...c...] truly makes it difficult for me to
accept some people's _sincerity_.

I am absolutely sincere in disliking and finding hard-to-teach this novel use of * in comprehensions.

Yours, David...

P.S. It's very artificial to assume user are unable to use 'from itertools import chain' to try to make chain() seem more cumbersome than it is.  Likewise, I would like flatten() in itertools, but I assume the usual pattern would be importing the function itself.

--
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.