Index: Doc/library/os.rst =================================================================== --- Doc/library/os.rst (revision 79422) +++ Doc/library/os.rst (working copy) @@ -437,7 +437,12 @@ is slightly deceptive; on Unix platforms, sockets and pipes are also referenced by file descriptors. +The :meth:`~file.fileno` method can be used to obtain the file descriptor +associated with a file object when required. Note that using the file +descriptor directly will bypass the file object methods, ignoring aspects such +as internal buffering of data. + .. function:: close(fd) Close file descriptor *fd*. Availability: Unix, Windows. @@ -546,6 +551,11 @@ Truncate the file corresponding to file descriptor *fd*, so that it is at most *length* bytes in size. Availability: Unix. + .. note:: + This function is intended for low-level I/O and must be applied to a file + descriptor as returned by :func:`os.open`. To truncate a "file object" + returned by the built-in function :func:`open` or :func:`fdopen`, use its + :meth:`~file.truncate` method. .. function:: isatty(fd)