Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(6)

Side by Side Diff: Doc/library/io.rst

Issue 10639: reindent.py converts newlines to platform default
Patch Set: Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Doc/library/http.cookies.rst ('k') | Doc/library/logging.handlers.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`io` --- Core tools for working with streams 1 :mod:`io` --- Core tools for working with streams
2 ================================================= 2 =================================================
3 3
4 .. module:: io 4 .. module:: io
5 :synopsis: Core tools for working with streams. 5 :synopsis: Core tools for working with streams.
6 .. moduleauthor:: Guido van Rossum <guido@python.org> 6 .. moduleauthor:: Guido van Rossum <guido@python.org>
7 .. moduleauthor:: Mike Verdone <mike.verdone@gmail.com> 7 .. moduleauthor:: Mike Verdone <mike.verdone@gmail.com>
8 .. moduleauthor:: Mark Russell <mark.russell@zen.co.uk> 8 .. moduleauthor:: Mark Russell <mark.russell@zen.co.uk>
9 .. moduleauthor:: Antoine Pitrou <solipsis@pitrou.net> 9 .. moduleauthor:: Antoine Pitrou <solipsis@pitrou.net>
10 .. moduleauthor:: Amaury Forgeot d'Arc <amauryfa@gmail.com> 10 .. moduleauthor:: Amaury Forgeot d'Arc <amauryfa@gmail.com>
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 enough data; unlike their :class:`RawIOBase` counterparts, they will 384 enough data; unlike their :class:`RawIOBase` counterparts, they will
385 never return ``None``. 385 never return ``None``.
386 386
387 Besides, the :meth:`read` method does not have a default 387 Besides, the :meth:`read` method does not have a default
388 implementation that defers to :meth:`readinto`. 388 implementation that defers to :meth:`readinto`.
389 389
390 A typical :class:`BufferedIOBase` implementation should not inherit from a 390 A typical :class:`BufferedIOBase` implementation should not inherit from a
391 :class:`RawIOBase` implementation, but wrap one, like 391 :class:`RawIOBase` implementation, but wrap one, like
392 :class:`BufferedWriter` and :class:`BufferedReader` do. 392 :class:`BufferedWriter` and :class:`BufferedReader` do.
393 393
394 :class:`BufferedIOBase` provides or overrides these methods and attribute in 394 :class:`BufferedIOBase` provides or overrides these members in addition to
395 addition to those from :class:`IOBase`: 395 those from :class:`IOBase`:
396 396
397 .. attribute:: raw 397 .. attribute:: raw
398 398
399 The underlying raw stream (a :class:`RawIOBase` instance) that 399 The underlying raw stream (a :class:`RawIOBase` instance) that
400 :class:`BufferedIOBase` deals with. This is not part of the 400 :class:`BufferedIOBase` deals with. This is not part of the
401 :class:`BufferedIOBase` API and may not exist on some implementations. 401 :class:`BufferedIOBase` API and may not exist on some implementations.
402 402
403 .. method:: detach() 403 .. method:: detach()
404 404
405 Separate the underlying raw stream from the buffer and return it. 405 Separate the underlying raw stream from the buffer and return it.
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 699
700 Read until newline or EOF and return a single ``str``. If the stream is 700 Read until newline or EOF and return a single ``str``. If the stream is
701 already at EOF, an empty string is returned. 701 already at EOF, an empty string is returned.
702 702
703 .. method:: write(s) 703 .. method:: write(s)
704 704
705 Write the string *s* to the stream and return the number of characters 705 Write the string *s* to the stream and return the number of characters
706 written. 706 written.
707 707
708 708
709 .. class:: TextIOWrapper(buffer, encoding=None, errors=None, newline=None, \ 709 .. class:: TextIOWrapper(buffer, encoding=None, errors=None, newline=None, line_ buffering=False)
710 line_buffering=False, write_through=False)
711 710
712 A buffered text stream over a :class:`BufferedIOBase` binary stream. 711 A buffered text stream over a :class:`BufferedIOBase` binary stream.
713 It inherits :class:`TextIOBase`. 712 It inherits :class:`TextIOBase`.
714 713
715 *encoding* gives the name of the encoding that the stream will be decoded or 714 *encoding* gives the name of the encoding that the stream will be decoded or
716 encoded with. It defaults to :func:`locale.getpreferredencoding`. 715 encoded with. It defaults to :func:`locale.getpreferredencoding`.
717 716
718 *errors* is an optional string that specifies how encoding and decoding 717 *errors* is an optional string that specifies how encoding and decoding
719 errors are to be handled. Pass ``'strict'`` to raise a :exc:`ValueError` 718 errors are to be handled. Pass ``'strict'`` to raise a :exc:`ValueError`
720 exception if there is an encoding error (the default of ``None`` has the same 719 exception if there is an encoding error (the default of ``None`` has the same
721 effect), or pass ``'ignore'`` to ignore errors. (Note that ignoring encoding 720 effect), or pass ``'ignore'`` to ignore errors. (Note that ignoring encoding
722 errors can lead to data loss.) ``'replace'`` causes a replacement marker 721 errors can lead to data loss.) ``'replace'`` causes a replacement marker
723 (such as ``'?'``) to be inserted where there is malformed data. When 722 (such as ``'?'``) to be inserted where there is malformed data. When
724 writing, ``'xmlcharrefreplace'`` (replace with the appropriate XML character 723 writing, ``'xmlcharrefreplace'`` (replace with the appropriate XML character
725 reference) or ``'backslashreplace'`` (replace with backslashed escape 724 reference) or ``'backslashreplace'`` (replace with backslashed escape
726 sequences) can be used. Any other error handling name that has been 725 sequences) can be used. Any other error handling name that has been
727 registered with :func:`codecs.register_error` is also valid. 726 registered with :func:`codecs.register_error` is also valid.
728 727
729 *newline* can be ``None``, ``''``, ``'\n'``, ``'\r'``, or ``'\r\n'``. It 728 *newline* can be ``None``, ``''``, ``'\n'``, ``'\r'``, or ``'\r\n'``. It
730 controls the handling of line endings. If it is ``None``, universal newlines 729 controls the handling of line endings. If it is ``None``, universal newlines
731 is enabled. With this enabled, on input, the lines endings ``'\n'``, 730 is enabled. With this enabled, on input, the lines endings ``'\n'``,
732 ``'\r'``, or ``'\r\n'`` are translated to ``'\n'`` before being returned to 731 ``'\r'``, or ``'\r\n'`` are translated to ``'\n'`` before being returned to
733 the caller. Conversely, on output, ``'\n'`` is translated to the system 732 the caller. Conversely, on output, ``'\n'`` is translated to the system
734 default line separator, :data:`os.linesep`. If *newline* is any other of its 733 default line separator, :data:`os.linesep`. If *newline* is any other of its
735 legal values, that newline becomes the newline when the file is read and it 734 legal values, that newline becomes the newline when the file is read and it
736 is returned untranslated. On output, ``'\n'`` is converted to the *newline*. 735 is returned untranslated. On output, ``'\n'`` is converted to the *newline*.
737 736
738 If *line_buffering* is ``True``, :meth:`flush` is implied when a call to 737 If *line_buffering* is ``True``, :meth:`flush` is implied when a call to
739 write contains a newline character. 738 write contains a newline character.
740
741 If *write_through* is ``True``, calls to :meth:`write` are guaranteed
742 not to be buffered: any data written on the :class:`TextIOWrapper`
743 object is immediately handled to its underlying binary *buffer*.
744
745 .. versionchanged:: 3.3
746 The *write_through* argument has been added.
747 739
748 :class:`TextIOWrapper` provides one attribute in addition to those of 740 :class:`TextIOWrapper` provides one attribute in addition to those of
749 :class:`TextIOBase` and its parents: 741 :class:`TextIOBase` and its parents:
750 742
751 .. attribute:: line_buffering 743 .. attribute:: line_buffering
752 744
753 Whether line buffering is enabled. 745 Whether line buffering is enabled.
754 746
755 747
756 .. class:: StringIO(initial_value='', newline=None) 748 .. class:: StringIO(initial_value='', newline=None)
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 they can arise from doing I/O in a :mod:`signal` handler. If a thread tries to 838 they can arise from doing I/O in a :mod:`signal` handler. If a thread tries to
847 renter a buffered object which it is already accessing, a :exc:`RuntimeError` is 839 renter a buffered object which it is already accessing, a :exc:`RuntimeError` is
848 raised. Note this doesn't prohibit a different thread from entering the 840 raised. Note this doesn't prohibit a different thread from entering the
849 buffered object. 841 buffered object.
850 842
851 The above implicitly extends to text files, since the :func:`open()` function 843 The above implicitly extends to text files, since the :func:`open()` function
852 will wrap a buffered object inside a :class:`TextIOWrapper`. This includes 844 will wrap a buffered object inside a :class:`TextIOWrapper`. This includes
853 standard streams and therefore affects the built-in function :func:`print()` as 845 standard streams and therefore affects the built-in function :func:`print()` as
854 well. 846 well.
855 847
OLDNEW
« no previous file with comments | « Doc/library/http.cookies.rst ('k') | Doc/library/logging.handlers.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+