Index: Doc/library/os.rst =================================================================== --- Doc/library/os.rst (revision 80077) +++ Doc/library/os.rst (working copy) @@ -655,14 +655,19 @@ .. function:: open(file, flags[, mode]) - Open the file *file* and set various flags according to *flags* and possibly its - mode according to *mode*. The default *mode* is ``0777`` (octal), and the - current umask value is first masked out. Return the file descriptor for the - newly opened file. Availability: Unix, Windows. + Open the file *file* using low level system call and return its descriptor + that can be used with other :ref:`os-fd-ops`. *flags* specify how the file + should be opened with constants defined in :ref:`os-open-flags` section below. + Optional *mode* parameter contains unix-like permissions for newly created + file and has value of ``0777`` (octal) by default. Current umask value is + first masked out. + Availability: Unix, Windows. - For a description of the flag and mode values, see the C run-time documentation; - flag constants (like :const:`O_RDONLY` and :const:`O_WRONLY`) are defined in - this module too (see :ref:`open-constants`). + .. warning:: + + On Windows this function opens file in text mode by default, while on Unix + all files opened as binary. To preserve crossplatform behavior add + :const:`O_BINARY` flag while on Windows. .. note:: @@ -736,15 +741,15 @@ :meth:`~file.write` method. -.. _open-constants: +.. _os-open-flags: -``open()`` flag constants -~~~~~~~~~~~~~~~~~~~~~~~~~ +``os.open`` flags +^^^^^^^^^^^^^^^^^ -The following constants are options for the *flags* parameter to the -:func:`~os.open` function. They can be combined using the bitwise OR operator -``|``. Some of them are not available on all platforms. For descriptions of -their availability and use, consult the :manpage:`open(2)` manual page on Unix +:func:`os.open` function understands the following *flag* constants that can be combined +using the bitwise OR operator ``|``. Some of them are not available on all platforms. +For descriptions and availability, consult the C run-time documentation: the +:manpage:`open(2)` manual page on Unix or `the MSDN `_ on Windows.