On Tue, Jan 26, 2021 at 10:22 AM Guido van Rossum <gu...@python.org> wrote: > > > Older Pythons may be easy to drop, but I'm not so sure about older unofficial > docs. The open() function is very popular and there must be millions of blog > posts with examples using it, most of them reading text files (written by > bloggers naive in Python but good at SEO). > > I would be very sad if the official recommendation had to become "[for the > most common case] avoid open(filename), use open_text(filename)". >
I agree that. But until we switch to the default encoding of open(), we must recommend to avoid `open(filename)` anyway. The default encoding of VS Code, Atom, Notepad is already UTF-8. Maybe, we need to update the tutorial (*) to use `encoding="utf-8"`. (*) https://docs.python.org/3.10/tutorial/inputoutput.html#reading-and-writing-files > BTW remind me what open_text() would do? How would it differ from open() with > the same arguments? That's too many messages back. > Current proposal is "open_utf8()". The differences from open() are: * There is no encoding parameter. It uses "utf-8" always. (*) * "b" is not allowed for mode. (*) Another option is to use "utf-8-sig" for reading and "utf-8" for writing. But it has some drawbacks. utf-8-sig has overhead because it is a wrapper implemented in Python. And TextIOWrapper has fast-paths for utf-8, but not for utf-8-sig. "utf-8-sig" may be not tested well compared to "utf-8". Regards, -- Inada Naoki <songofaca...@gmail.com> _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/BCMUOSHJOA36AKOWKQINNJZYAC2WIBUF/ Code of Conduct: http://python.org/psf/codeofconduct/