blob: 26fdda1255d9786a45e806faa5b3ca25093aee04 [file] [log] [blame]
Guido van Rossumcda3d7d1997-03-03 16:01:21 +00001\section{Standard Module \sectcode{StringIO}}
Guido van Rossum53209981997-07-17 16:29:04 +00002\label{module-StringIO}
Guido van Rossumcda3d7d1997-03-03 16:01:21 +00003
4\stmodindex{StringIO}
5
6This module implements a file-like class, \code{StringIO},
Fred Drakeaf8a0151998-01-14 14:51:31 +00007that reads and writes a string buffer (also known as \emph{memory
Guido van Rossumcda3d7d1997-03-03 16:01:21 +00008files}). See the description on file objects for operations.
9
10When a \code{StringIO} object is created, it can be initialized
11to an existing string by passing the string to the constructor.
12If no string is given, the \code{StringIO} will start empty.
13
Guido van Rossum53209981997-07-17 16:29:04 +000014The method \code{getvalue()} can be called to retrieve the entire
15contents of the ``file'' at any time before the \code{StringIO}
16object's \code{close()} method is called. Calling \code{close()} will
17free the memory buffer.