This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: io doc improvements
Type: behavior Stage: resolved
Components: Documentation, IO Versions: Python 3.1, Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: benjamin.peterson, docs@python, pitrou, skip.montanaro
Priority: normal Keywords: patch

Created on 2010-08-30 11:54 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
iodoc.patch pitrou, 2010-08-30 12:02
Messages (7)
msg115208 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-30 11:54
This is an improvement patch for the :mod:`io` documentation.
It adds an user-friendly overview, and makes a couple of other fixes/improvements.
There's a problem where I want to make a link to a glossary term while using the plural form ("abstract base classes"), and it doesn't work. Can someone help me?
msg115211 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-30 12:49
Ok, committed in r84357 (py3k) and r84358 (3.1). Backporting to 2.7 would be too much work.
msg115212 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2010-08-30 13:27
A couple wording comments:

"All streams are careful about the type of data you give to them"
would read better as "All streams accept specific types of data".

"The default mode is ``'r'`` (open for reading text, synonym of
``'rt'``)".  I liked the original wording better.

Finally, not specific to this change, but I wonder if rather than
having distinct io.StringIO and io.BytesIO classes it would be better
to have a single io.MemoryIO class which takes mode arguments just
like io.FileIO?  The correspondence between file-based and memory-
based i/o would be more one-to-one.  Such a class could be added
without breaking existing code by using the StringIO and BytesIO
classes as the back-end for a MemoryIO class.
msg115213 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-08-30 13:32
2010/8/30 Skip Montanaro <report@bugs.python.org>:
>
> Skip Montanaro <skip@pobox.com> added the comment:
>
> A couple wording comments:
>
> "All streams are careful about the type of data you give to them"
> would read better as "All streams accept specific types of data".
>
> "The default mode is ``'r'`` (open for reading text, synonym of
> ``'rt'``)".  I liked the original wording better.

Feel free to change it; it's been committed.

>
> Finally, not specific to this change, but I wonder if rather than
> having distinct io.StringIO and io.BytesIO classes it would be better
> to have a single io.MemoryIO class which takes mode arguments just
> like io.FileIO?  The correspondence between file-based and memory-
> based i/o would be more one-to-one.  Such a class could be added
> without breaking existing code by using the StringIO and BytesIO
> classes as the back-end for a MemoryIO class.

What advantage would that have?
msg115214 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-30 13:38
> "The default mode is ``'r'`` (open for reading text, synonym of
> ``'rt'``)".  I liked the original wording better.

Well, people use "r" in practice, and "rt" is a somewhat rarer
alternative. We could drop the "synonym..." part entirely.
msg115216 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2010-08-30 14:13
>> Finally, not specific to this change, but I wonder if rather than
    >> having distinct io.StringIO and io.BytesIO classes it would be better
    >> to have a single io.MemoryIO class which takes mode arguments just
    >> like io.FileIO?  The correspondence between file-based and memory-
    >> based i/o would be more one-to-one.  Such a class could be added
    >> without breaking existing code by using the StringIO and BytesIO
    >> classes as the back-end for a MemoryIO class.

    Benjamin> What advantage would that have?

File I/O and memory I/O would have more uniform in their APIs and thus be
easier to document, describe and use.  Currently, one class is used to do
file I/O.  The type of I/O done is controlled by the mode and buffering
flags.  Two distinct classes are used to do memory I/O.

If someone wanted to select between file and memory I/O at runtime it
wouldn't be possible to just swap the class using the current code.

Skip
msg115217 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-30 14:23
> File I/O and memory I/O would have more uniform in their APIs and thus be
> easier to document, describe and use.  Currently, one class is used to do
> file I/O.

That's wrong. Various classes are used for file I/O: FileIO,
Buffered{Reader,Writer,Random}, TextIOWrapper.

> If someone wanted to select between file and memory I/O at runtime it
> wouldn't be possible to just swap the class using the current code.

Why would you swap the class since the constructor arguments would be
different anyway?
History
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53924
2010-08-30 14:23:20pitrousetmessages: + msg115217
2010-08-30 14:13:38skip.montanarosetmessages: + msg115216
2010-08-30 13:38:52pitrousetmessages: + msg115214
2010-08-30 13:32:33benjamin.petersonsetmessages: + msg115213
2010-08-30 13:27:37skip.montanarosetnosy: + skip.montanaro
messages: + msg115212
2010-08-30 12:49:56pitrousetstatus: open -> closed
versions: - Python 2.7
messages: + msg115211

resolution: fixed
stage: patch review -> resolved
2010-08-30 12:02:01pitrousetfiles: + iodoc.patch
2010-08-30 12:01:51pitrousetfiles: - iodoc.patch
2010-08-30 11:54:39pitroucreate