blob: cf96dbb4719f1a4753a92bdedc0ec49f7ddab423 [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
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 Drake8fe533e1998-03-27 05:27:08 +000016\begin{methoddesc}{getvalue}{}
17Retrieve the entire contents of the ``file'' at any time before the
18\class{StringIO} object's \method{close()} method is called.
19\end{methoddesc}
20
21\begin{methoddesc}{close}{}
22Free the memory buffer.
23\end{methoddesc}