@@ -630,9 +630,9 @@ Text I/O
630630
631631.. class :: StringIO([initial_value[, encoding[, errors[, newline]]]])
632632
633- An in-memory stream for text. It in inherits :class: `TextIOWrapper `.
633+ An in-memory stream for text. It inherits :class: `TextIOWrapper `.
634634
635- Create a new StringIO stream with an inital value, encoding, error handling,
635+ Create a new StringIO stream with an initial value, encoding, error handling,
636636 and newline setting. See :class: `TextIOWrapper `\' s constructor for more
637637 information.
638638
@@ -641,8 +641,25 @@ Text I/O
641641
642642 .. method :: getvalue()
643643
644- Return a ``str `` containing the entire contents of the buffer.
644+ Return a ``str `` containing the entire contents of the buffer at any
645+ time before the :class: `StringIO ` object's :meth: `close ` method is
646+ called.
645647
648+ Example usage::
649+
650+ import io
651+
652+ output = io.StringIO()
653+ output.write('First line.\n')
654+ print('Second line.', file=output)
655+
656+ # Retrieve file contents -- this will be
657+ # 'First line.\nSecond line.\n'
658+ contents = output.getvalue()
659+
660+ # Close object and discard memory buffer --
661+ # .getvalue() will now raise an exception.
662+ output.close()
646663
647664.. class :: IncrementalNewlineDecoder
648665
0 commit comments