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: Error in tutorial section 7.2
Type: Stage:
Components: Documentation Versions:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: cvrebert, georg.brandl, melbourne, michael.foord, pjenvey, rhettinger
Priority: low Keywords:

Created on 2009-06-18 01:14 by melbourne, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (10)
msg89487 - (view) Author: david (melbourne) Date: 2009-06-18 01:14
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-
files
"Windows makes a distinction between text and binary files;
"the end-of-line characters in text files are automatically altered
"slightly when data is read or written.

Windows does not make a distinction between text and binary files:
http://msdn.microsoft.com/en-us/library/aa365430(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa365467(VS.85).aspx

Nor does it automatically alter end-of-line characters.

It is not clear what distinction Python makes between text and binary 
files. Do those options do anything on any platform? Is jPython 
different than cPython? And does Python automatically alter end-of-line 
characters?
msg89491 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-06-18 06:57
Even if the Win32 API functions do not have a concept of text/binary
files, the C library functions that MS provides, and Python uses, have.

See http://msdn.microsoft.com/en-us/library/yeby3zcb(VS.71).aspx
msg89496 - (view) Author: david (melbourne) Date: 2009-06-18 08:18
So, it's wrong, and it's not helpful unless you already know what it 
means, but it works for someone who doesn't need the Python tutorial!

I'm gobsmacked.

If "the C libraries that Python uses" have the concept of Text/Binary, 
why not just say so?

Conversely, if you are ashamed to admit that use of Python requires 
knowledge of C, why not just change the tutorial to TALK ABOUT PYTHON?

I never wanted to back anyone into a corner: I'm just amazed at all 
this. It's wrong, fix it, why defend it?
msg89497 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-06-18 09:03
A small improvement could be made:

- Windows makes a distinction between text and binary files
+ Python on Windows makes a distinction between text and binary files

The meaning should have been obvious as-is, but the fact of the matter
is that the OP is "gobsmacked" and "amazed" so surely something must be
done ;-)
msg89510 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-06-18 22:04
I'm -0 about that change.

However, I'd like to defend the original wording; it is *not* Python
that makes the text/binary distinction.  Python just calls fopen(),
which is what portable C programs are supposed to do, with the mode it
is given by the programmer in open().  Python neither ships nor owns the
C library.  For the Python programmer however, it is irrelevant which
part of the system that Python uses has a particular behavior, he just
notes that *on that system* it can be observed.

How about "On Windows, a distinction is made ..."? <half-wink>
msg89511 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-06-18 22:19
The wording as it stands just seems plain wrong. 

Either "Python on Windows" or "On Windows" is better - the former over
the latter but either...
msg89515 - (view) Author: david (melbourne) Date: 2009-06-19 00:12
If this is like to be non-portable to jPython, I'd like to be told.

However, I can see that the tutorial may be the wrong place to mention 
that.
msg89516 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-06-19 00:13
This behavior of Python when reading files is so fundamental that I
can't imagine Jython doesn't behave the same way. (IronPython certainly
has the same behavior.)
msg89518 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2009-06-19 00:57
Jython 2.5 behaves in the same way
msg92570 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-09-13 16:14
Committed revision 74779.
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50550
2009-09-13 16:14:12michael.foordsetmessages: + msg92570
2009-06-19 00:57:01pjenveysetnosy: + pjenvey
messages: + msg89518
2009-06-19 00:13:37michael.foordsetmessages: + msg89516
2009-06-19 00:12:22melbournesetmessages: + msg89515
2009-06-18 22:19:42michael.foordsetnosy: + michael.foord
messages: + msg89511
2009-06-18 22:04:29georg.brandlsetmessages: + msg89510
2009-06-18 09:03:29rhettingersetpriority: low
nosy: + rhettinger
messages: + msg89497

2009-06-18 08:18:49melbournesetmessages: + msg89496
2009-06-18 06:57:57georg.brandlsetstatus: open -> closed
resolution: works for me
messages: + msg89491
2009-06-18 01:43:04cvrebertsetnosy: + cvrebert
2009-06-18 01:14:20melbournecreate