[Python-ideas] Fwd: Fwd: Fwd: unpacking generalisations for list comprehension
Sven R. Kunze
srkunze at mail.de
Mon Oct 17 15:35:41 EDT 2016
On 17.10.2016 20:38, David Mertz wrote:
> 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.
I see what you are trying to do here and I appreciate it. Just one
thought from my practical experience: I haven't had a single usage for
levels > 1. levels==1 is basically * which I have at least one example
for. Maybe, that relates to the fact that we asked our devs to use names
(as in attributes or dicts) instead of deeply nested list/tuple structures.
Do you think it would make sense to start a new thread just for the sake
of readability?
> 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.
You are consistent at least. You don't teach * in list displays, no
matter if regular lists or comprehensions. +1
> 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.
I am sorry but it is cumbersome.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20161017/64730089/attachment.html>
More information about the Python-ideas
mailing list