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

Method write_text

Lib/pathlib/__init__.py:997–1008  ·  view source on GitHub ↗

Open the file in text mode, write to it, and close the file.

(self, data, encoding=None, errors=None, newline=None)

Source from the content-addressed store, hash-verified

995 return f.write(view)
996
997 def write_text(self, data, encoding=None, errors=None, newline=None):
998 """
999 Open the file in text mode, write to it, and close the file.
1000 """
1001 # Call io.text_encoding() here to ensure any warning is raised at an
1002 # appropriate stack level.
1003 encoding = io.text_encoding(encoding)
1004 if not isinstance(data, str):
1005 raise TypeError('data must be str, not %s' %
1006 data.__class__.__name__)
1007 with self.open(mode='w', encoding=encoding, errors=errors, newline=newline) as f:
1008 return f.write(data)
1009
1010 _remove_leading_dot = operator.itemgetter(slice(2, None))
1011 _remove_trailing_slash = operator.itemgetter(slice(-1))

Callers 13

write_glossary_jsonFunction · 0.95
saveMethod · 0.95
scriptMethod · 0.95
test_files_listMethod · 0.95
inject_traceFunction · 0.45
finishMethod · 0.45
prepare_wasmFunction · 0.45
_generate_index_htmlMethod · 0.45
_generate_file_htmlMethod · 0.45
_build_stencilsMethod · 0.45
build.pyFile · 0.45

Calls 2

openMethod · 0.95
writeMethod · 0.45

Tested by 2

scriptMethod · 0.76
test_files_listMethod · 0.76