summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2007-09-26 01:10:12 (GMT)
committerSkip Montanaro <skip@pobox.com>2007-09-26 01:10:12 (GMT)
commit4e02c503e789337b07cc14ece3f5adbf23732c89 (patch)
tree94b8c2b5afc2e09a261f28c3ba57b2d334bd26b2 /Doc
parent5dde61d0b96f6e22ef887e7cc262c479d9787eb7 (diff)
downloadcpython-4e02c503e789337b07cc14ece3f5adbf23732c89.zip
cpython-4e02c503e789337b07cc14ece3f5adbf23732c89.tar.gz
cpython-4e02c503e789337b07cc14ece3f5adbf23732c89.tar.bz2
Clarify the difference between text and binary files. I'm not sure the
tutorial is the right place to mention a file object's encoding.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/tutorial/inputoutput.rst22
1 files changed, 14 insertions, 8 deletions
diff --git a/Doc/tutorial/inputoutput.rst b/Doc/tutorial/inputoutput.rst
index 2f4cdd3..cfea7bb 100644
--- a/Doc/tutorial/inputoutput.rst
+++ b/Doc/tutorial/inputoutput.rst
@@ -197,14 +197,20 @@ automatically added to the end. ``'r+'`` opens the file for both reading and
writing. The *mode* argument is optional; ``'r'`` will be assumed if it's
omitted.
-On Windows and the Macintosh, ``'b'`` appended to the mode opens the file in
-binary mode, so there are also modes like ``'rb'``, ``'wb'``, and ``'r+b'``.
-Windows makes a distinction between text and binary files; the end-of-line
-characters in text files are automatically altered slightly when data is read or
-written. This behind-the-scenes modification to file data is fine for ASCII
-text files, but it'll corrupt binary data like that in :file:`JPEG` or
-:file:`EXE` files. Be very careful to use binary mode when reading and writing
-such files.
+``'b'`` appended to the mode opens the file in binary mode, so there are
+also modes like ``'rb'``, ``'wb'``, and ``'r+b'``. Python distinguishes
+between text and binary files. Binary files are read and written without
+any data transformation. In text mode, platform-specific newline
+representations are automatically converted to newlines when read and
+newline characters are automatically converted to the proper
+platform-specific representation when written. This makes writing portable
+code which reads or writes text files easier. In addition, when reading
+from or writing to text files, the data are automatically decoded or
+encoding, respectively, using the encoding associated with the file.
+
+This behind-the-scenes modification to file data is fine for text files, but
+will corrupt binary data like that in :file:`JPEG` or :file:`EXE` files. Be
+very careful to use binary mode when reading and writing such files.
.. _tut-filemethods: