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: Make 'rt' the default for open in docs
Type: enhancement Stage: needs patch
Components: Documentation Versions: Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, facundobatista, terry.reedy
Priority: normal Keywords:

Created on 2020-04-24 20:16 by facundobatista, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg367219 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2020-04-24 20:16
This is mostly a confusion about 'r' being a synonym of 'rt', while it's more explicit if we consider 'r' as one default, and 't' as other (as other parts of the documentation do).

Doing `help(open)` we get:

    mode is an optional string that specifies the mode in which the file
    is opened. It defaults to 'r' which means open for reading in text
    mode. 

Later in the same text it's stated:

    The default mode is 'rt' (open for reading text).

Which reflects the wording I want to have, but is confusing that initially it said a different thing.

If we get the html docs, it says "The default mode is 'r' (open for reading text, synonym of 'rt')."
    
Why not just stating that the default mode is 'rt'?
msg367885 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2020-05-01 20:43
The inconsistency might be a residue of the transition from 2.x.  But the 'r' versus 'rt' confusion originates in the code and signature.   The text 't' default is built into the code, while the read 'r' default is in the 'mode=r' part of the signature.

If text 't' were only a signature default, from 'mode=rt', then changing 'read-text' to 'something_else-text' would require including the 't', as in 'wt', etc.  But it is not.  On the other hand, passing mode as 'b' or using 'mode=b' is a ValueError because one of 'r', 'w', or 'a', optionally followed by '+', is required.

I think the doc entry for open might stand a change to make this a bit clearer, but I don't have a specific proposal yet.
History
Date User Action Args
2022-04-11 14:59:29adminsetgithub: 84562
2020-05-01 20:43:05terry.reedysetnosy: + terry.reedy
messages: + msg367885
2020-04-24 20:16:00facundobatistacreate