| LEFT | RIGHT |
| 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 to which the resulting :class:`FileIO` object will give access. | 472 to which the resulting :class:`FileIO` object will give access. |
| 473 | 473 |
| 474 The *mode* can be ``'r'``, ``'w'`` or ``'a'`` for reading (default), writing, | 474 The *mode* can be ``'r'``, ``'w'`` or ``'a'`` for reading (default), writing, |
| 475 or appending. The file will be created if it doesn't exist when opened for | 475 or appending. The file will be created if it doesn't exist when opened for |
| 476 writing or appending; it will be truncated when opened for writing. Add a | 476 writing or appending; it will be truncated when opened for writing. Add a |
| 477 ``'+'`` to the mode to allow simultaneous reading and writing. | 477 ``'+'`` to the mode to allow simultaneous reading and writing. |
| 478 | 478 |
| 479 The :meth:`read` (when called with a positive argument), :meth:`readinto` | 479 The :meth:`read` (when called with a positive argument), :meth:`readinto` |
| 480 and :meth:`write` methods on this class will only make one system call. | 480 and :meth:`write` methods on this class will only make one system call. |
| 481 | 481 |
| 482 A custom opener can be used by passing a callable as *opener*. The | 482 A custom opener can be used by passing a callable as *opener*. The underlying |
| 483 underlying file descriptor for the file object is then obtained by calling | 483 file descriptor for the file object is then obtained by calling *opener* with |
| 484 *opener* with (*name*, *flags*). | 484 (*name*, *flags*). *opener* must return an open file descriptor (passing |
| 485 :mod:`os.open` as *opener* results in functionality similar to passing |
| 486 ``None``). |
| 485 | 487 |
| 486 In addition to the attributes and methods from :class:`IOBase` and | 488 In addition to the attributes and methods from :class:`IOBase` and |
| 487 :class:`RawIOBase`, :class:`FileIO` provides the following data | 489 :class:`RawIOBase`, :class:`FileIO` provides the following data |
| 488 attributes and methods: | 490 attributes and methods: |
| 489 | 491 |
| 490 .. attribute:: mode | 492 .. attribute:: mode |
| 491 | 493 |
| 492 The mode as given in the constructor. | 494 The mode as given in the constructor. |
| 493 | 495 |
| 494 .. attribute:: name | 496 .. attribute:: name |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 they can arise from doing I/O in a :mod:`signal` handler. If a thread tries to | 852 they can arise from doing I/O in a :mod:`signal` handler. If a thread tries to |
| 851 renter a buffered object which it is already accessing, a :exc:`RuntimeError` is | 853 renter a buffered object which it is already accessing, a :exc:`RuntimeError` is |
| 852 raised. Note this doesn't prohibit a different thread from entering the | 854 raised. Note this doesn't prohibit a different thread from entering the |
| 853 buffered object. | 855 buffered object. |
| 854 | 856 |
| 855 The above implicitly extends to text files, since the :func:`open()` function | 857 The above implicitly extends to text files, since the :func:`open()` function |
| 856 will wrap a buffered object inside a :class:`TextIOWrapper`. This includes | 858 will wrap a buffered object inside a :class:`TextIOWrapper`. This includes |
| 857 standard streams and therefore affects the built-in function :func:`print()` as | 859 standard streams and therefore affects the built-in function :func:`print()` as |
| 858 well. | 860 well. |
| 859 | 861 |
| LEFT | RIGHT |