On Sat, Jan 23, 2021 at 10:47 AM Chris Angelico <ros...@gmail.com> wrote:
>
>
> Highly dubious. I'd rather focus on just moving to UTF-8 as the
> default, rather than bringing in a new function - especially with such
> a confusing name.
>
> What exactly are the blockers on making open(fn) use UTF-8 by default?

Backward compatibility. That's what PEP 597 tries to solve.

1. Add optional warning for `open()` call without specifying
`encoding` option. (PEP 597)
2. (Several years later) Make the warning default.
3. (Several years later) Change the default encoding.

When (2) happens, users are forced to write `encoding="utf-8"` to
suppress the warning.

But note that the default encoding is "utf-8" already in (most) Linux
including WSL, macOS, iOS, and Android.
And Windows user can read ASCII text files without specifying
`encoding` regardless default encoding is legacy codec or "utf-8".
So adding `, encoding="utf-8"` everywhere `open()` is used might be tedious job.

On the other hand, if we add `open_text()`:

* Replacing open with open_text is easier than adding `, encoding="utf-8"`.
* Teachers can teach to use `open_text` to open text files. Students
can use "utf-8" by default without knowing about what encoding is.

So `open_text()` can provide better developer experience, without
waiting 10 years.

> Can the proposals be written with that as the ultimate goal (even if
> it's going to take X versions and multiple deprecation phases), rather
> than aiming for a messy goal where people aren't sure which function
> to use?
>

Ultimate goal is make the "utf-8" default. But I don't know when we
can change it.
So I focus on what we can do in near future (< 5 years, I hope).

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/KGQFKMX2GBDIYITJCM6MHAS5ZGUA6YDL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to