Lines Matching defs:mode

73     mode: str = "r"
89 mode is an optional string that specifies the mode in which the file
91 mode. Other common values are 'w' for writing (truncating the file if
95 In text mode, if encoding is not specified the encoding used is platform
97 (For reading and writing raw bytes use binary mode and leave encoding
107 'b' binary mode
108 't' text mode (default)
112 The default mode is 'rt' (open for reading text). For binary random
113 access, the mode 'w+b' opens and truncates the file to 0 bytes, while
114 'r+b' opens the file without truncation. The 'x' mode implies 'w' and
119 binary mode (appending 'b' to the mode argument) return contents as
120 bytes objects without any decoding. In text mode (the default, or when
121 't' is appended to the mode argument), the contents of the file are
126 Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
127 line buffering (only usable in text mode), and an integer > 1 to indicate
141 file. This should only be used in text mode. The default encoding is
146 be handled---this argument should not be used in binary mode. Pass
154 mode). It can be None, '', '\n', '\r', and '\r\n'. It works as
157 * On input, if newline is None, universal newlines mode is
160 caller. If it is '', universal newline mode is enabled, but line
181 open() returns a file object whose type depends on the mode, and
183 are performed. When open() is used to open a file in a text mode ('w',
185 a file in a binary mode, the returned class varies: in read binary
186 mode, it returns a BufferedReader; in write binary and append binary
187 modes, it returns a BufferedWriter, and in read/write mode, it returns
192 opened in a text mode, and for bytes a BytesIO can be used like a file
193 opened in a binary mode.
197 _io_open_impl(PyObject *module, PyObject *file, const char *mode,
232 /* Decode mode */
233 for (i = 0; i < strlen(mode); i++) {
234 char c = mode[i];
263 if (strchr(mode+i+1, c)) {
265 PyErr_Format(PyExc_ValueError, "invalid mode: '%s'", mode);
282 "can't have text and binary mode at once");
288 "must have exactly one of create/read/write/append mode");
294 "binary mode doesn't take an encoding argument");
300 "binary mode doesn't take an errors argument");
306 "binary mode doesn't take a newline argument");
313 "binary mode, the default buffer size will be used",
342 modeobj = PyUnicode_FromString(mode);
404 "unknown mode: '%s'", mode);
433 if (PyObject_SetAttr(wrapper, &_Py_ID(mode), modeobj) < 0)
463 (i.e. "locale" or "utf-8" depends on UTF-8 mode).