[Python-ideas] Fwd: unpacking generalisations for list comprehension
Steven D'Aprano
steve at pearwood.info
Sat Oct 15 04:53:37 EDT 2016
On Thu, Oct 13, 2016 at 01:30:45PM -0700, Neil Girdhar wrote:
> From a CPython implementation standpoint, we specifically blocked this code
> path, and it is only a matter of unblocking it if we want to support this.
I find that difficult to believe. The suggested change seems like it
should be much bigger than just removing a block. Can you point us to
the relevant code?
In any case, it isn't really the difficulty of implementation that is
being questioned. Many things are easy to implement, but we still
don't do them. The real questions here are:
(1) Should we overload list comprehensions as sugar for a flatten()
function?
(2) If so, should we spell that [*t for t in iterable]?
Actually the answer to (1) should be "we already do". We just spell it:
[x for t in iterable for x in t]
--
Steve
More information about the Python-ideas
mailing list