[New-bugs-announce] [issue26001] Tutorial: write() does not expect string in binary mode

Dimitri Papadopoulos Orfanos report at bugs.python.org
Sun Jan 3 08:56:15 EST 2016


New submission from Dimitri Papadopoulos Orfanos:

About section "7.2.1. Methods of File Objects" of the tutorial:


1. Method read() is documented as follows:
reads some quantity of data and returns it as a string or bytes object.

Indeed read() returns a string in text mode and bytes in binary mode. For the sake of clarity, I suggest changing to:

reads some quantity of data and returns it as a string (in text mode) or bytes object (in binary mode).

This might seem long-winded but I believe it would help those moving from Python 2 to Python 3.


2. Method write() is documented as follows:

To write something other than a string, it needs to be converted to a string first

While this is correct in text mode, it is wrong in binary mode. May I suggest:

To write something other than a string (in text mode) or bytes object (in binary mode), it needs to be converted first

----------
assignee: docs at python
components: Documentation
messages: 257418
nosy: Dimitri Papadopoulos Orfanos, docs at python
priority: normal
severity: normal
status: open
title: Tutorial: write() does not expect string in binary mode
versions: Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26001>
_______________________________________


More information about the New-bugs-announce mailing list