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

Method write

Lib/_pyio.py:1753–1765  ·  view source on GitHub ↗

Write bytes b to file, return number written. Only makes one system call, so not all of the data may be written. The number of bytes actually written is returned. In non-blocking mode, returns None if the write would block.

(self, b)

Source from the content-addressed store, hash-verified

1751 return None
1752
1753 def write(self, b):
1754 """Write bytes b to file, return number written.
1755
1756 Only makes one system call, so not all of the data may be written.
1757 The number of bytes actually written is returned. In non-blocking mode,
1758 returns None if the write would block.
1759 """
1760 self._checkClosed()
1761 self._checkWritable()
1762 try:
1763 return os.write(self._fd, b)
1764 except BlockingIOError:
1765 return None
1766
1767 def seek(self, pos, whence=SEEK_SET):
1768 """Move to new file position.

Callers 12

testBytesOpenMethod · 0.95
testUtf8BytesOpenMethod · 0.95
testTruncateMethod · 0.95
bug801631Method · 0.95
testAppendMethod · 0.95
writelinesMethod · 0.45
_flush_unlockedMethod · 0.45
writeMethod · 0.45
writeMethod · 0.45
writeMethod · 0.45
__init__Method · 0.45

Calls 2

_checkWritableMethod · 0.95
_checkClosedMethod · 0.45

Tested by 6

testBytesOpenMethod · 0.76
testUtf8BytesOpenMethod · 0.76
testTruncateMethod · 0.76
bug801631Method · 0.76
testAppendMethod · 0.76