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

Function _stringify

Lib/tkinter/__init__.py:63–88  ·  view source on GitHub ↗

Internal function.

(value)

Source from the content-addressed store, hash-verified

61
62
63def _stringify(value):
64 """Internal function."""
65 if isinstance(value, (list, tuple)):
66 if len(value) == 1:
67 value = _stringify(value[0])
68 if _magic_re.search(value):
69 value = '{%s}' % value
70 else:
71 value = '{%s}' % _join(value)
72 else:
73 if isinstance(value, bytes):
74 value = str(value, 'latin1')
75 else:
76 value = str(value)
77 if not value:
78 value = '{}'
79 elif _magic_re.search(value):
80 # add '\' before special characters and spaces
81 value = _magic_re.sub(r'\\\1', value)
82 value = value.replace('\n', r'\n')
83 value = _space_re.sub(r'\\\1', value)
84 if value[0] == '"':
85 value = '\\' + value
86 elif value[0] == '"' or _space_re.search(value):
87 value = '{%s}' % value
88 return value
89
90
91def _flatten(seq):

Callers 2

_format_optvalueFunction · 0.90
_optionsMethod · 0.85

Calls 5

strFunction · 0.85
_joinFunction · 0.70
searchMethod · 0.45
subMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…