On 4 July 2018 at 11:25, Steven D'Aprano firstname.lastname@example.org 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
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`.