On 4 July 2018 at 11:25, Steven D'Aprano <[email protected]> wrote:
> On Wed, Jul 04, 2018 at 11:08:05AM +0100, Ivan Levkivskyi 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. > > However, if this is a class it can support adding new elements, merge the > > groupeddicts, etc. > > defaultdicts support adding new elements, and they have an update method > same as regular dicts :-) > Except that updating will not do what I want. Merging two groupeddicts is not just `one.update(other)` Moreover, using just an update with regular dicts will do something bug-prone, it will add every group from `other` as an element to the corresponding group in `one`. -- Ivan
_______________________________________________ Python-ideas mailing list [email protected] https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
