[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
On Sat, Jan 23, 2021 at 10:47 AM Chris Angelico 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? Back

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
On Sat, Jan 23, 2021 at 2:43 PM Random832 wrote: > > On Fri, Jan 22, 2021, at 20:34, Inada Naoki wrote: > > * Default encoding is "utf-8". > > it might be worthwhile to be a little more sophisticated than this. > > Notepad itself uses character set detection [it might not be reasonable to do > th

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Chris Angelico
On Sat, Jan 23, 2021 at 9:04 PM Inada Naoki wrote: > > On Sat, Jan 23, 2021 at 10:47 AM Chris Angelico 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 e

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Paul Sokolovsky
Hello, On Sat, 23 Jan 2021 19:04:08 +0900 Inada Naoki wrote: > On Sat, Jan 23, 2021 at 10:47 AM Chris Angelico > 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. >

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
On Sat, Jan 23, 2021 at 7:13 PM Chris Angelico wrote: > > > 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 withou

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
On Sat, Jan 23, 2021 at 7:31 PM Paul Sokolovsky wrote: > > > > * Replacing open with open_text is easier than adding `, > > encoding="utf-8"`. > > How is it easier, if "open_text" exists only in imagination, while > encoding="utf-8" has been there all this time? > Note that the warning is not ena

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Steven D'Aprano
On Sat, Jan 23, 2021 at 01:31:28PM +0300, Paul Sokolovsky wrote: > > * Teachers can teach to use `open_text` to open text files. Students > > can use "utf-8" by default without knowing about what encoding is. > > Let's also add max_int(), min_int(), max_float(), min_float() builtins. > Teachers c

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Steven D'Aprano
On Sat, Jan 23, 2021 at 12:40:55AM -0500, Random832 wrote: > On Fri, Jan 22, 2021, at 20:34, Inada Naoki wrote: > > * Default encoding is "utf-8". > > it might be worthwhile to be a little more sophisticated than this. > > Notepad itself uses character set detection [it might not be > reasonable

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Stephen J. Turnbull
Chris Angelico writes: > On Sat, Jan 23, 2021 at 12:37 PM Inada Naoki wrote: > > ## 1. Add `io.open_text()`, builtin `open_text()`, and > > `pathlib.Path.open_text()`. > > > > All functions are same to `io.open()` or `Path.open()`, except: > > > > * Default encoding is "utf-8". I wonder i

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Chris Angelico
On Sat, Jan 23, 2021 at 11:34 PM Stephen J. Turnbull wrote: > > 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. > > I expect there are several bodies of users who will experience that as > quite obn

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Stephen J. Turnbull
Steven D'Aprano writes: > On Sat, Jan 23, 2021 at 12:40:55AM -0500, Random832 wrote: > > On Fri, Jan 22, 2021, at 20:34, Inada Naoki wrote: > > > * Default encoding is "utf-8". > > > > it might be worthwhile to be a little more sophisticated than this. > > > > Notepad itself uses character

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Barry Scott
> On 23 Jan 2021, at 11:00, Steven D'Aprano wrote: > > On Sat, Jan 23, 2021 at 12:40:55AM -0500, Random832 wrote: >> On Fri, Jan 22, 2021, at 20:34, Inada Naoki wrote: >>> * Default encoding is "utf-8". >> >> it might be worthwhile to be a little more sophisticated than this. >> >> Notepad i

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Chris Angelico
On Sun, Jan 24, 2021 at 2:31 AM Barry Scott wrote: > I think that you are going to create a bug magnet if you attempt to auto > detect the encoding. > > First problem I see is that the file may be a pipe and then you will block > until you have enough data to do the auto detect. > > Second problem

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread MRAB
On 2021-01-23 10:11, Chris Angelico wrote: [snip] Okay. If the goal is to make UTF-8 the default, may I request that PEP 597 say so, please? With a heading of "deprecation", it's not really clear what its actual goal is. From the sound of things - and it's still possible I'm misreading PEP 59

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Cameron Simpson
On 23Jan2021 22:00, Stephen J. Turnbull wrote: >I see very little use in detecting the BOMs. I haven't seen a UTF-16 >BOM in the wild in a decade (as usual for me, that's Japan-specific, >and may be limited to the academic community as well), and the UTF-8 >BOM is a no-op if the default is UTF-8

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Random832
On Sat, Jan 23, 2021, at 05:06, Inada Naoki wrote: > On Sat, Jan 23, 2021 at 2:43 PM Random832 wrote: > > > > On Fri, Jan 22, 2021, at 20:34, Inada Naoki wrote: > > > * Default encoding is "utf-8". > > > > it might be worthwhile to be a little more sophisticated than this. > > > > Notepad itself u

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Random832
On Sat, Jan 23, 2021, at 08:00, Stephen J. Turnbull wrote: > I see very little use in detecting the BOMs. I haven't seen a UTF-16 > BOM in the wild in a decade (as usual for me, that's Japan-specific, > and may be limited to the academic community as well), and the UTF-8 > BOM is a no-op if the de

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Steven D'Aprano
On Sat, Jan 23, 2021 at 11:59:12PM +1100, Chris Angelico wrote: > So Windows is being a pain in the behind, once again, because it > doesn't move forward. *cough* That would be called "backwards compatibility" :-) Microsoft's attitude towards backwards compatibility is probably even stricter

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Guido van Rossum
I have definitely seen BOMs written by Notepad on Windows 10. Why can’t the future be that open() in text mode guesses the encoding? -- --Guido (mobile) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-idea

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread MRAB
On 2021-01-24 01:14, Guido van Rossum wrote: I have definitely seen BOMs written by Notepad on Windows 10. Why can’t the future be that open() in text mode guesses the encoding? "In the face of ambiguity, refuse the temptation to guess." ___ Python-i

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Inada Naoki
On Sun, Jan 24, 2021 at 10:17 AM Guido van Rossum wrote: > > I have definitely seen BOMs written by Notepad on Windows 10. > > Why can’t the future be that open() in text mode guesses the encoding? I don't like guessing. As a Japanese, I have seen many mojibake caused by the wrong guess. I don't

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Steven D'Aprano
On Sun, Jan 24, 2021 at 01:32:28AM +, MRAB wrote: > On 2021-01-24 01:14, Guido van Rossum wrote: > >I have definitely seen BOMs written by Notepad on Windows 10. > > > >Why can’t the future be that open() in text mode guesses the encoding? > > > "In the face of ambiguity, refuse the temptation

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Matt Wozniski
On Sat, Jan 23, 2021 at 9:22 PM Inada Naoki wrote: > On Sun, Jan 24, 2021 at 10:17 AM Guido van Rossum > wrote: > > > > I have definitely seen BOMs written by Notepad on Windows 10. > > > > Why can’t the future be that open() in text mode guesses the encoding? > > I don't like guessing. As a Jap

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Chris Angelico
On Sun, Jan 24, 2021 at 2:46 PM Matt Wozniski wrote: > 2. At the same time as the deprecation is announced, introduce a new > __future__ import named "utf8_open" or something like that, to opt into the > future behavior of `open` defaulting to utf-8-sig or utf-8 when opening a > file in text mo

[Python-ideas] Re: Adding `open_text()` builtin function. (relating to PEP 597)

2021-01-23 Thread Matt Wozniski
On Sat, Jan 23, 2021 at 10:51 PM Chris Angelico wrote: > On Sun, Jan 24, 2021 at 2:46 PM Matt Wozniski wrote: > > 2. At the same time as the deprecation is announced, introduce a new > __future__ import named "utf8_open" or something like that, to opt into the > future behavior of `open` default