Lines Matching defs:mode

6 "open($module, /, file, mode=\'r\', buffering=-1, encoding=None,\n"
18 "mode is an optional string that specifies the mode in which the file\n"
20 "mode. Other common values are \'w\' for writing (truncating the file if\n"
24 "In text mode, if encoding is not specified the encoding used is platform\n"
26 "(For reading and writing raw bytes use binary mode and leave encoding\n"
36 "\'b\' binary mode\n"
37 "\'t\' text mode (default)\n"
41 "The default mode is \'rt\' (open for reading text). For binary random\n"
42 "access, the mode \'w+b\' opens and truncates the file to 0 bytes, while\n"
43 "\'r+b\' opens the file without truncation. The \'x\' mode implies \'w\' and\n"
48 "binary mode (appending \'b\' to the mode argument) return contents as\n"
49 "bytes objects without any decoding. In text mode (the default, or when\n"
50 "\'t\' is appended to the mode argument), the contents of the file are\n"
55 "Pass 0 to switch buffering off (only allowed in binary mode), 1 to select\n"
56 "line buffering (only usable in text mode), and an integer > 1 to indicate\n"
70 "file. This should only be used in text mode. The default encoding is\n"
75 "be handled---this argument should not be used in binary mode. Pass\n"
83 "mode). It can be None, \'\', \'\\n\', \'\\r\', and \'\\r\\n\'. It works as\n"
86 "* On input, if newline is None, universal newlines mode is\n"
89 " caller. If it is \'\', universal newline mode is enabled, but line\n"
110 "open() returns a file object whose type depends on the mode, and\n"
112 "are performed. When open() is used to open a file in a text mode (\'w\',\n"
114 "a file in a binary mode, the returned class varies: in read binary\n"
115 "mode, it returns a BufferedReader; in write binary and append binary\n"
116 "modes, it returns a BufferedWriter, and in read/write mode, it returns\n"
121 "opened in a text mode, and for bytes a BytesIO can be used like a file\n"
122 "opened in a binary mode.");
128 _io_open_impl(PyObject *module, PyObject *file, const char *mode,
136 static const char * const _keywords[] = {"file", "mode", "buffering", "encoding", "errors", "newline", "closefd", "opener", NULL};
141 const char *mode = "r";
159 _PyArg_BadArgument("open", "argument 'mode'", "str", args[1]);
163 mode = PyUnicode_AsUTF8AndSize(args[1], &mode_length);
164 if (mode == NULL) {
167 if (strlen(mode) != (size_t)mode_length) {
264 return_value = _io_open_impl(module, file, mode, buffering, encoding, errors, newline, closefd, opener);
278 "(i.e. \"locale\" or \"utf-8\" depends on UTF-8 mode).\n"