<commit_before>\section{\module{StringIO} ---
         Read and write strings as files}

\declaremodule{standard}{StringIO}
\modulesynopsis{Read and write strings as if they were files.}


This module implements a file-like class, \class{StringIO},
that reads and writes a string buffer (also known as \emph{memory
files}).  See the description of file objects for operations (section
\ref{bltin-file-objects}).

\begin{classdesc}{StringIO}{\optional{buffer}}
When a \class{StringIO} object is created, it can be initialized
to an existing string by passing the string to the constructor.
If no string is given, the \class{StringIO} will start empty.

The \class{StringIO} object can accept either Unicode or 8-bit
strings, but mixing the two may take some care.  If both are used,
8-bit strings that cannot be interpreted as 7-bit \ASCII{} (that<commit_msg>SF bug #1180392: StringIO's docs should mention overwriting of initial value<commit_after>\section{\module{StringIO} ---
         Read and write strings as files}

\declaremodule{standard}{StringIO}
\modulesynopsis{Read and write strings as if they were files.}


This module implements a file-like class, \class{StringIO},
that reads and writes a string buffer (also known as \emph{memory
files}).  See the description of file objects for operations (section
\ref{bltin-file-objects}).

\begin{classdesc}{StringIO}{\optional{buffer}}
When a \class{StringIO} object is created, it can be initialized
to an existing string by passing the string to the constructor.
If no string is given, the \class{StringIO} will start empty.
In both cases, the initial file position starts at zero.

The \class{StringIO} object can accept either Unicode or 8-bit
strings, but mixing the two may take some care.  If both are used,
8-bit strings that cannot be interpreted as 7-bit \ASCII{} (that
{'fraction_non_alphanumeric': 0.08333333333333333, 'fraction_numerical': 0.007080610021786492, 'mean_word_length': 4.566666666666666, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '734693', 'n_tokens_mistral': 505, 'n_tokens_neox': 486, 'n_words': 241}