summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-12-19 21:01:10 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-12-19 21:01:10 (GMT)
commite812d29b52c597363d8d2c2615def653701a0efc (patch)
treeb2bfee34b41a6d46bc731d1e48b4c17b1380ff78 /Lib
parentd86e9d7616dbc6e9c836803619294e07757ba091 (diff)
downloadcpython-e812d29b52c597363d8d2c2615def653701a0efc.zip
cpython-e812d29b52c597363d8d2c2615def653701a0efc.tar.gz
cpython-e812d29b52c597363d8d2c2615def653701a0efc.tar.bz2
Issue #7545: improve documentation of the `buffering` argument in io.open().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/_pyio.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index b0da045..5fe928b 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -92,6 +92,21 @@ def open(file, mode="r", buffering=None,
allowed in binary mode), 1 to set line buffering, and an integer > 1
for full buffering.
+ buffering is an optional integer used to set the buffering policy.
+ Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
+ line buffering (only usable in text mode), and an integer > 1 to indicate
+ the size of a fixed-size chunk buffer. When no buffering argument is
+ given, the default buffering policy works as follows:
+
+ * Binary files are buffered in fixed-size chunks; the size of the buffer
+ is chosen using a heuristic trying to determine the underlying device's
+ "block size" and falling back on `io.DEFAULT_BUFFER_SIZE`.
+ On many systems, the buffer will typically be 4096 or 8192 bytes long.
+
+ * "Interactive" text files (files for which isatty() returns True)
+ use line buffering. Other text files use the policy described above
+ for binary files.
+
encoding is the name of the encoding used to decode or encode the
file. This should only be used in text mode. The default encoding is
platform dependent, but any encoding supported by Python can be