1 \section{\module{StringIO
} ---
2 Read and write strings as if they were files.
}
3 \declaremodule{standard
}{StringIO
}
6 \modulesynopsis{Read and write strings as if they were files.
}
9 This module implements a file-like class,
\class{StringIO
},
10 that reads and writes a string buffer (also known as
\emph{memory
11 files
}). See the description on file objects for operations.
13 \begin{classdesc
}{StringIO
}{\optional{buffer
}}
14 When a
\class{StringIO
} object is created, it can be initialized
15 to an existing string by passing the string to the constructor.
16 If no string is given, the
\class{StringIO
} will start empty.
19 The following methods of
\class{StringIO
} objects require special
22 \begin{methoddesc
}{getvalue
}{}
23 Retrieve the entire contents of the ``file'' at any time before the
24 \class{StringIO
} object's
\method{close()
} method is called.
27 \begin{methoddesc
}{close
}{}
28 Free the memory buffer.
32 \section{\module{cStringIO
} ---
33 Faster version of
\module{StringIO
}, but not subclassable.
}
34 \declaremodule{builtin
}{cStringIO
}
36 \modulesynopsis{Faster version of
\module{StringIO
}, but not subclassable.
}
39 % This section was written by Fred L. Drake, Jr. <fdrake@acm.org>
41 The module
\module{cStringIO
} provides an interface similar to that of
42 the
\module{StringIO
} module. Heavy use of
\class{StringIO.StringIO
}
43 objects can be made more efficient by using the function
44 \function{StringIO()
} from this module instead.
46 Since this module provides a factory function which returns objects of
47 built-in types, there's no way to build your own version using
48 subclassing. Use the original
\module{StringIO
} module in that case.