[Python-ideas] Allow a group by operation for dict comprehension

Michael Selik mike at selik.org
Thu Jun 28 22:57:27 EDT 2018


On Thu, Jun 28, 2018, 6:46 PM Nicolas Rolin <nicolas.rolin at tiime.fr> wrote:

> The questions I should have asked In my original post was :
> - Is splitting lists into sublists (by grouping elements) a high level
> enough construction to be worthy of a nice integration in the comprehension
> syntax ?
>

My intuition is no, it's not important enough to alter the syntax, despite
being an important task.

- In which case, is there a way to find a simple syntax that is not too
> confusing ?
>

If you'd like to give it a shot, try to find something which is currently
invalid syntax, but does not break compatibility. The latter criteria means
no new keywords. The syntax should look nice as a single line with
reasonably verbose variable names.

One issue is that Python code is mostly 1-dimensional, characters in a
line, and you're trying to express something which is 2-dimensional, in a
sense. There's only so much you can do without newlines and indentation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180628/8a9ef9fa/attachment.html>


More information about the Python-ideas mailing list