MCPcopy Index your code
hub / github.com/python/cpython / _splitdict

Function _splitdict

Lib/tkinter/__init__.py:128–149  ·  view source on GitHub ↗

Return a properly formatted dict built from Tcl list pairs. If cut_minus is True, the supposed '-' prefix will be removed from keys. If conv is specified, it is used to convert values. Tcl list is expected to contain an even number of elements.

(tk, v, cut_minus=True, conv=None)

Source from the content-addressed store, hash-verified

126
127
128def _splitdict(tk, v, cut_minus=True, conv=None):
129 """Return a properly formatted dict built from Tcl list pairs.
130
131 If cut_minus is True, the supposed '-' prefix will be removed from
132 keys. If conv is specified, it is used to convert values.
133
134 Tcl list is expected to contain an even number of elements.
135 """
136 t = tk.splitlist(v)
137 if len(t) % 2:
138 raise RuntimeError('Tcl list representing a dict is expected '
139 'to contain an even number of elements')
140 it = iter(t)
141 dict = {}
142 for key, value in zip(it, it):
143 key = str(key)
144 if cut_minus and key[0] == '-':
145 key = key[1:]
146 if conv:
147 value = conv(value)
148 dict[key] = value
149 return dict
150
151class _VersionInfoType(collections.namedtuple('_VersionInfoType',
152 ('major', 'minor', 'micro', 'releaselevel', 'serial'))):

Callers 8

_val_or_dictFunction · 0.90
mapMethod · 0.90
setMethod · 0.90
_grid_configureMethod · 0.85
wm_attributesMethod · 0.85
pack_infoMethod · 0.85
place_infoMethod · 0.85
grid_infoMethod · 0.85

Calls 3

strFunction · 0.85
convFunction · 0.85
splitlistMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…