1 \section{Standard Module
\module{StringIO
}}
2 \label{module-StringIO
}
6 This module implements a file-like class,
\class{StringIO
},
7 that reads and writes a string buffer (also known as
\emph{memory
8 files
}). See the description on file objects for operations.
10 \begin{classdesc
}{StringIO
}{\optional{buffer
}}
11 When a
\class{StringIO
} object is created, it can be initialized
12 to an existing string by passing the string to the constructor.
13 If no string is given, the
\class{StringIO
} will start empty.
16 The following methods of
\class{StringIO
} objects require special
19 \begin{methoddesc
}{getvalue
}{}
20 Retrieve the entire contents of the ``file'' at any time before the
21 \class{StringIO
} object's
\method{close()
} method is called.
24 \begin{methoddesc
}{close
}{}
25 Free the memory buffer.
29 \section{Built-in Module
\module{cStringIO
}}
30 \bimodindex{cStringIO
}
31 \label{module-cStringIO
}
33 % This section was written by Fred L. Drake, Jr. <fdrake@acm.org>
35 The module
\module{cStringIO
} provides an interface similar to that of
36 the
\module{StringIO
} module. Heavy use of
\class{StringIO.StringIO
}
37 objects can be made more efficient by using the function
38 \function{StringIO()
} from this module instead.
40 Since this module provides a factory function which returns objects of
41 built-in types, there's no way to build your own version using
42 subclassing. Use the original
\module{StringIO
} module in that case.