New submission from STINNER Victor <[EMAIL PROTECTED]>: 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(). ---------- components: Library (Lib) files: explicit_open.patch keywords: needs review, patch, patch messages: 74727 nosy: haypo severity: normal status: open title: open(): use keyword only for arguments other than file and mode versions: Python 3.0 Added file: http://bugs.python.org/file11784/explicit_open.patch _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4121> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com