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

Method writeTmp

Lib/test/test_fileinput.py:42–48  ·  view source on GitHub ↗
(self, content, *, mode='w')

Source from the content-addressed store, hash-verified

40 # Write a content (str or bytes) to temp file, and return the
41 # temp file's name.
42 def writeTmp(self, content, *, mode='w'): # opening in text mode is the default
43 fd, name = tempfile.mkstemp()
44 self.addCleanup(os_helper.unlink, name)
45 encoding = None if "b" in mode else "utf-8"
46 with open(fd, mode, encoding=encoding) as f:
47 f.write(content)
48 return name
49
50class LineReader:
51

Calls 3

addCleanupMethod · 0.80
openFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected