• Home
  • Raw
  • Download

Lines Matching +full:non +full:- +full:read +full:- +full:only

1 :mod:`io` --- Core tools for working with streams
17 Under Python 2.x, this is proposed as an alternative to the built-in
44 streams. :class:`BytesIO` is a simple stream of in-memory bytes.
50 (:class:`BufferedIOBase`). Finally, :class:`~io.StringIO` is an in-memory
53 Argument names are not part of the specification, and only the arguments of
58 ----------------
66 .. function:: open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=…
88 --------- ---------------------------------------------------------------
109 platform-dependent encoding or using the specified *encoding* if given.
112 Pass 0 to switch buffering off (only allowed in binary mode), 1 to select
113 line buffering (only usable in text mode), and an integer > 1 to indicate
114 the size of a fixed-size chunk buffer. When no *buffering* argument is
117 * Binary files are buffered in fixed-size chunks; the size of the buffer
127 This should only be used in text mode. The default encoding is platform
147 *newline* controls how :term:`universal newlines` works (it only applies to
156 lines are only terminated by the given string, and the line ending is
175 :class:`BufferedIOBase`. The exact class varies: in read binary mode, it
177 it returns a :class:`BufferedWriter`, and in read/write mode, it returns a
190 Error raised when blocking would occur on a non-blocking stream. It inherits
209 ----------------
218 implementations represent a file that cannot be read, written or
221 Even though :class:`IOBase` does not declare :meth:`read`, :meth:`readinto`,
227 The basic type used for binary data read from or written to a file is
248 :keyword:`with` statement's suite is finished---even if an exception occurs::
262 only the first call, however, will have an effect.
277 for read-only and non-blocking streams.
286 Return ``True`` if the stream can be read from. If ``False``, :meth:`read`
289 .. method:: readline(limit=-1)
291 Read and return one line from the stream. If *limit* is specified, at
292 most *limit* bytes will be read.
298 .. method:: readlines(hint=-1)
300 Read and return a list of lines from the stream. *hint* can be specified
301 to control the number of lines read: no more lines will be read if the
313 * :data:`SEEK_SET` or ``0`` -- start of the stream (the default);
315 * :data:`SEEK_CUR` or ``1`` -- current stream position; *offset* may
317 * :data:`SEEK_END` or ``2`` -- end of the stream; *offset* is usually
340 (on most systems, additional bytes are zero-filled, on Windows they're
366 Raw binary I/O typically provides low-level access to an underlying OS
367 device or API, and does not try to encapsulate it in high-level primitives
373 .. method:: read(n=-1)
375 Read up to *n* bytes from the object and return them. As a convenience,
376 if *n* is unspecified or -1, :meth:`readall` is called. Otherwise,
377 only one system call is ever made. Fewer than *n* bytes may be
381 If the object is in non-blocking mode and no bytes are available,
386 Read and return all the bytes from the stream until EOF, using multiple
391 Read up to len(b) bytes into *b*, and return the number
392 of bytes read. The object *b* should be a pre-allocated, writable
394 If the object is in non-blocking mode and no
404 especially if it is in non-blocking mode. ``None`` is returned if the
407 this method returns, so the implementation should only access *b*
416 The main difference with :class:`RawIOBase` is that methods :meth:`read`,
417 :meth:`readinto` and :meth:`write` will try (respectively) to read as much
422 underlying raw stream is in non-blocking mode and cannot take or give
426 Besides, the :meth:`read` method does not have a default
455 .. method:: read(n=-1)
457 Read and return up to *n* bytes. If the argument is omitted, ``None``, or
458 negative, data is read and returned until EOF is reached. An empty bytes
464 one raw read will be issued, and a short result does not imply that EOF is
468 non blocking-mode, and has no data available at the moment.
470 .. method:: read1(n=-1)
472 Read and return up to *n* bytes, with at most one call to the underlying
473 raw stream's :meth:`~RawIOBase.read` method. This can be useful if you
479 Read up to len(b) bytes into *b*, and return the number of bytes read.
480 The object *b* should be a pre-allocated, writable array of bytes,
483 Like :meth:`read`, multiple reads may be issued to the underlying raw
487 non blocking-mode, and has no data available at the moment.
499 When in non-blocking mode, a :exc:`BlockingIOError` is raised if the
504 so the implementation should only access *b* during the method call.
508 ------------
512 :class:`FileIO` represents an OS-level file containing bytes data.
519 * an integer representing the number of an existing OS-level file descriptor
527 The :meth:`read` (when called with a positive argument), :meth:`readinto`
528 and :meth:`write` methods on this class will only make one system call.
545 ----------------
547 Buffered I/O streams provide a higher-level interface to an I/O device
552 A stream implementation using an in-memory bytes buffer. It inherits
567 In :class:`BytesIO`, this is the same as :meth:`read`.
572 A buffer providing higher-level access to a readable, sequential
588 single read on the raw stream is done to satisfy the call. The number of
591 .. method:: read([n])
593 Read and return *n* bytes, or if *n* is not given or negative, until EOF
594 or if the read call would block in non-blocking mode.
598 Read and return up to *n* bytes with only one call on the raw stream. If
599 at least one byte is buffered, only buffered bytes are returned.
600 Otherwise, one raw stream read call is made.
605 A buffer providing higher-level access to a writeable, sequential
635 When in non-blocking mode, a :exc:`BlockingIOError` is raised
658 objects -- one readable, the other writeable -- into a single bidirectional
680 --------
727 .. method:: read(n=-1)
729 Read and return at most *n* characters from the stream as a single
732 .. method:: readline(limit=-1)
734 Read until newline or EOF and return a single ``unicode``. If the
737 If *limit* is specified, at most *limit* characters will be read.
750 *offset* must be zero, which is a no-operation (all other values
802 other legal values, input lines are only terminated by the given string,
824 An in-memory stream for unicode text. It inherits :class:`TextIOWrapper`.
832 The default is to consider only ``\n`` characters as ends of lines and
844 called. Newlines are decoded as if by :meth:`~TextIOBase.read`,
855 # Retrieve file contents -- this will be
859 # Close object and discard memory buffer --
874 ---------------
885 By reading and writing only large chunks of data even when the user asks
905 :class:`~io.StringIO`, however, is a native in-memory unicode container and will
908 Multi-threading
911 :class:`FileIO` objects are thread-safe to the extent that the operating
912 system calls (such as ``read(2)`` under Unix) they are wrapping are thread-safe
920 :class:`TextIOWrapper` objects are not thread-safe.
934 includes standard streams and therefore affects the built-in function