File Methods
fileno()
Return the integer file descriptor used by the underlying operating system.
file.fileno()
file.fileno() returns the integer file descriptor assigned to the open file by the OS.
Returns
An integer representing the operating system file descriptor.
Try it
Run it and change it
import tempfile
with tempfile.NamedTemporaryFile(mode='w+', delete=True) as f:
fd = f.fileno()
print('Is integer FD:', isinstance(fd, int))Worth knowing
- Low-level OS operations: File descriptors are used with the
osmodule functions likeos.read(),os.write(), andos.fstat().