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.

Author vstinner
Recipients vstinner
Date 2008-10-14.11:01:59
SpamBayes Score 1.07758e-05
Marked as misclassified No
Message-id <1223982122.27.0.317312591734.issue4121@psf.upfronthosting.co.za>
In-reply-to
Content
In the C library, fopen() have two arguments: filename and the mode, 
and open() has three arguments: filename, mode and flags. In Python, 
open() has 7 arguments:
 - file
 - mode
 - buffering
 - encoding
 - errors
 - newline
 - closefd

Most programs only use the two first arguments, but buffering is 
sometimes set. Eg. open(filename, "r") or open(filename, "wb", 0).

I think that only the file and mode arguments are easy to understand, 
the others have to be specified using their name. Eg. 
open(filename, "wb", buffering=0) or open(filename, "r", 
encoding="GBK").

I wrote a patch to use keyword only arguments, and another to fix some 
libraries and the unit tests.

explicit_open.patch needs review. I don't know the best way to create 
a dictionary. Py_BuildValue() may be used to write a smaller patch.

--

open(file, mode, *, buffering, ...) may be replaced by open(file, 
mode, buffering, *, ...) to keep compatibility with Python2, but I 
read somewhere that Python3 breaks the compatibility and a 2to3 fixer 
can be used to fix open().
History
Date User Action Args
2008-10-14 11:02:02vstinnersetrecipients: + vstinner
2008-10-14 11:02:02vstinnersetmessageid: <1223982122.27.0.317312591734.issue4121@psf.upfronthosting.co.za>
2008-10-14 11:02:01vstinnerlinkissue4121 messages
2008-10-14 11:02:00vstinnercreate