We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ab20193 commit 5e5309dCopy full SHA for 5e5309d
1 file changed
src/utils.py
@@ -12,21 +12,19 @@ class MethodDispatcher(dict):
12
multiple keys so accessing any one of the items in the original
13
list-like object returns the matching value
14
15
- md = MethodDispatcher({["foo", "bar"]:"baz"})
+ md = MethodDispatcher({("foo", "bar"):"baz"})
16
md["foo"] == "baz"
17
18
A default value which can be set through the default attribute.
19
"""
20
21
def __init__(self, items=()):
22
- _dictEntries = []
23
for name,value in items:
24
if type(name) in (list, tuple, frozenset, set):
25
for item in name:
26
- _dictEntries.append((item, value))
+ self[item] = value
27
else:
28
- _dictEntries.append((name, value))
29
- dict.__init__(self, _dictEntries)
+ self[name] = value
30
self.default = None
31
32
def __getitem__(self, key):
0 commit comments