gruns / gruns/orderedmultidict

add magic methods as seen in set() and elsewhere

Open
#21 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
68
Forks
15
PR merge metrics
No merged PRs in 30d

Description

Add functionality such that
`>>> omdict(a=1, b=2) |= {'a': 'hello world'}`
fully merges/updates (`add` all members) the omdict
`>>> omdict([('a', 1), ('b', 2), ('a', 'hello world')])`
and similar functionality for `|` but returns a new object instead.

I suggest also then to use
`>>> omdict(a=1, b=2) += {'a': 'hello world'}`
to produce a more "regular" update
`>>> omdict([('b', 2), ('a', 'hello world')])`
and once again `+` produces a new object instead

newer versions of python will have dictionary insertion order as default, but this is still useful in the case that order does not particularly matter, but then if it does these operations should obviously also work with OrderedDict and other omdict instances to preserve order.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.