Guido van Rossum | cda3d7d | 1997-03-03 16:01:21 +0000 | [diff] [blame] | 1 | \section{Standard Module \sectcode{StringIO}} |
Guido van Rossum | 5320998 | 1997-07-17 16:29:04 +0000 | [diff] [blame] | 2 | \label{module-StringIO} |
Guido van Rossum | cda3d7d | 1997-03-03 16:01:21 +0000 | [diff] [blame] | 3 | |
| 4 | \stmodindex{StringIO} |
| 5 | |
Fred Drake | 8fe533e | 1998-03-27 05:27:08 +0000 | [diff] [blame] | 6 | This module implements a file-like class, \class{StringIO}, |
Fred Drake | af8a015 | 1998-01-14 14:51:31 +0000 | [diff] [blame] | 7 | that reads and writes a string buffer (also known as \emph{memory |
Guido van Rossum | cda3d7d | 1997-03-03 16:01:21 +0000 | [diff] [blame] | 8 | files}). See the description on file objects for operations. |
| 9 | |
Fred Drake | 8fe533e | 1998-03-27 05:27:08 +0000 | [diff] [blame] | 10 | \begin{classdesc}{StringIO}{\optional{buffer}} |
| 11 | When a \class{StringIO} object is created, it can be initialized |
Guido van Rossum | cda3d7d | 1997-03-03 16:01:21 +0000 | [diff] [blame] | 12 | to an existing string by passing the string to the constructor. |
Fred Drake | 8fe533e | 1998-03-27 05:27:08 +0000 | [diff] [blame] | 13 | If no string is given, the \class{StringIO} will start empty. |
| 14 | \end{classdesc} |
Guido van Rossum | cda3d7d | 1997-03-03 16:01:21 +0000 | [diff] [blame] | 15 | |
Fred Drake | 8fe533e | 1998-03-27 05:27:08 +0000 | [diff] [blame] | 16 | \begin{methoddesc}{getvalue}{} |
| 17 | Retrieve 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}{} |
| 22 | Free the memory buffer. |
| 23 | \end{methoddesc} |