blob: 0088ec32dfcc71e0a4a36037e3d28962a81a3fac [file] [log] [blame]
Fred Drake3a0351c1998-04-04 07:23:21 +00001\section{Standard Module \module{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
Fred Drake8fe533e1998-03-27 05:27:08 +00006This module implements a file-like class, \class{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
Fred Drake8fe533e1998-03-27 05:27:08 +000010\begin{classdesc}{StringIO}{\optional{buffer}}
11When a \class{StringIO} object is created, it can be initialized
Guido van Rossumcda3d7d1997-03-03 16:01:21 +000012to an existing string by passing the string to the constructor.
Fred Drake8fe533e1998-03-27 05:27:08 +000013If no string is given, the \class{StringIO} will start empty.
14\end{classdesc}
Guido van Rossumcda3d7d1997-03-03 16:01:21 +000015
Fred Drake7e9383a1998-04-11 18:05:24 +000016The following methods of \class{StringIO} objects require special
17mention:
18
Fred Drake8fe533e1998-03-27 05:27:08 +000019\begin{methoddesc}{getvalue}{}
20Retrieve the entire contents of the ``file'' at any time before the
21\class{StringIO} object's \method{close()} method is called.
22\end{methoddesc}
23
24\begin{methoddesc}{close}{}
25Free the memory buffer.
26\end{methoddesc}