On this page
os.read
Prev: os.putenv | Up: os | Next: os.readlink
Rel: os.abort, os.access, os.chdir, os.chmod
Ref: docs.python.org — os.read
Tags: #public #python3 #stdlib #os
Import
import os
from os import read
Signature & Overview
os.read(fd, length, /)
Read from a file descriptor. Returns a bytes object.
Usage
import os
r_fd, w_fd = os.pipe()
try:
os.write(w_fd, b"abc")
assert os.read(r_fd, 10) == b"abc"
finally:
os.close(r_fd); os.close(w_fd)
Gotchas
- May return fewer than
nbytes: Low-level syscall wrapper; returnsb""at EOF. Use buffered file objects (open()) for normal I/O.
REPL Inspect
from os import read
help(read)
Linked from
Related notes
- tuts/python3/stdlib_module/os/putenv Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/readlink Linked here; links to this page; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/os/abort Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/access Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chdir Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chmod Linked here; shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/chown shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/close shared tags: #os, #stdlib
- tuts/python3/stdlib_module/os/cpu_count shared tags: #os, #stdlib