diff options
author | Georg Brandl <georg@python.org> | 2008-05-30 06:27:09 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-05-30 06:27:09 (GMT) |
commit | 2932d9376e4d89f401ad25f9dfab7fdbf25779cc (patch) | |
tree | b3e631e5f29f1bf6cb38a46e6c3ce340a4dbcd96 /Doc/library/io.rst | |
parent | eec0d5f8fdba2cc577402b9da5207842eb30b491 (diff) | |
download | cpython-2932d9376e4d89f401ad25f9dfab7fdbf25779cc.zip cpython-2932d9376e4d89f401ad25f9dfab7fdbf25779cc.tar.gz cpython-2932d9376e4d89f401ad25f9dfab7fdbf25779cc.tar.bz2 |
#3007: remove stringio docs and fix a few nits in io docs.
Diffstat (limited to 'Doc/library/io.rst')
-rw-r--r-- | Doc/library/io.rst | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst index d80d265..543bb37 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -630,9 +630,9 @@ Text I/O .. class:: StringIO([initial_value[, encoding[, errors[, newline]]]]) - An in-memory stream for text. It in inherits :class:`TextIOWrapper`. + An in-memory stream for text. It inherits :class:`TextIOWrapper`. - Create a new StringIO stream with an inital value, encoding, error handling, + Create a new StringIO stream with an initial value, encoding, error handling, and newline setting. See :class:`TextIOWrapper`\'s constructor for more information. @@ -641,8 +641,25 @@ Text I/O .. method:: getvalue() - Return a ``str`` containing the entire contents of the buffer. + Return a ``str`` containing the entire contents of the buffer at any + time before the :class:`StringIO` object's :meth:`close` method is + called. + Example usage:: + + import io + + output = io.StringIO() + output.write('First line.\n') + print('Second line.', file=output) + + # Retrieve file contents -- this will be + # 'First line.\nSecond line.\n' + contents = output.getvalue() + + # Close object and discard memory buffer -- + # .getvalue() will now raise an exception. + output.close() .. class:: IncrementalNewlineDecoder |