MCPcopy Index your code
hub / github.com/datacamp/pythonwhat / IndexedDict

Class IndexedDict

pythonwhat/parsing.py:67–83  ·  view source on GitHub ↗

Wrapper around OrderedDict that allows access via item position or key

Source from the content-addressed store, hash-verified

65
66
67class IndexedDict(Mapping):
68 """Wrapper around OrderedDict that allows access via item position or key"""
69
70 def __init__(self, *args, **kwargs):
71 self._od = OrderedDict(*args, **kwargs)
72
73 def __getitem__(self, k):
74 try:
75 return list(self._od.values())[k]
76 except TypeError:
77 return self._od[k]
78
79 def __len__(self):
80 return self._od.__len__()
81
82 def __iter__(self):
83 return self._od.__iter__()
84
85
86class Parser(ast.NodeVisitor):

Callers 3

bind_argsFunction · 0.90
get_call_partMethod · 0.85
parse_nodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected