Merged revisions 82368 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r82368 | benjamin.peterson | 2010-06-29 10:18:02 -0500 (Tue, 29 Jun 2010) | 1 line

  group cStringIO docs under its factory function
........
This commit is contained in:
Benjamin Peterson 2010-06-29 15:26:43 +00:00
parent 34d2ebec5f
commit 60fa0bf4bd
1 changed files with 20 additions and 15 deletions

View File

@ -71,18 +71,21 @@ The module :mod:`cStringIO` provides an interface similar to that of the
made more efficient by using the function :func:`StringIO` from this module made more efficient by using the function :func:`StringIO` from this module
instead. instead.
Since this module provides a factory function which returns objects of built-in
types, there's no way to build your own version using subclassing. It's not .. function:: StringIO([s])
Return a StringIO-like stream for reading or writing.
Since this is a factory function which returns objects of built-in types,
there's no way to build your own version using subclassing. It's not
possible to set attributes on it. Use the original :mod:`StringIO` module in possible to set attributes on it. Use the original :mod:`StringIO` module in
those cases. those cases.
Unlike the memory files implemented by the :mod:`StringIO` module, those Unlike the :mod:`StringIO` module, this module is not able to accept Unicode
provided by this module are not able to accept Unicode strings that cannot be strings that cannot be encoded as plain ASCII strings. Calling
encoded as plain ASCII strings. :func:`StringIO` with a Unicode string parameter populates the object with
the buffer representation of the Unicode string instead of encoding the
Calling :func:`StringIO` with a Unicode string parameter populates string.
the object with the buffer representation of the Unicode string, instead of
encoding the string.
Another difference from the :mod:`StringIO` module is that calling Another difference from the :mod:`StringIO` module is that calling
:func:`StringIO` with a string parameter creates a read-only object. Unlike an :func:`StringIO` with a string parameter creates a read-only object. Unlike an
@ -90,6 +93,8 @@ object created without a string parameter, it does not have write methods.
These objects are not generally visible. They turn up in tracebacks as These objects are not generally visible. They turn up in tracebacks as
:class:`StringI` and :class:`StringO`. :class:`StringI` and :class:`StringO`.
The following data objects are provided as well: The following data objects are provided as well: