[Python-ideas] Where should grouping() live (was: grouping / dict of lists)

Michael Selik mike at selik.org
Wed Jul 4 14:03:30 EDT 2018


On Wed, Jul 4, 2018, 3:11 AM Ivan Levkivskyi <levkivskyi at gmail.com> wrote:

> Replying to the question in subject, I think it would be better in
> collections as a class.
> Having it just as a function doesn't  buy much, because one can do the
> same with three lines and a defaultdict.
>

Four lines. You'll need to convert from defaultdict back to a basic dict to
avoid mistaken inserts. For some use cases.


However, if this is a class it can support adding new elements, merge the
> groupeddicts, etc.
>
> --
> Ivan
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180704/8413abd1/attachment.html>


More information about the Python-ideas mailing list