MCPcopy Create free account
hub / github.com/ipython/ipython / __dict_invert

Method __dict_invert

IPython/utils/ipstruct.py:217–229  ·  view source on GitHub ↗

Helper function for merge. Takes a dictionary whose values are lists and returns a dict with the elements of each list as keys and the original keys as values.

(self, data)

Source from the content-addressed store, hash-verified

215 return self
216
217 def __dict_invert(self, data):
218 """Helper function for merge.
219
220 Takes a dictionary whose values are lists and returns a dict with
221 the elements of each list as keys and the original keys as values.
222 """
223 outdict = {}
224 for k,lst in data.items():
225 if isinstance(lst, str):
226 lst = lst.split()
227 for entry in lst:
228 outdict[entry] = k
229 return outdict
230
231 def dict(self):
232 return self

Callers 1

mergeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected