FWIW, using the ascii function does have the problem that Unicose
characters will be escaped, even if the terminal could have handled them
perfectly fine.

--
Ryan (ライアン)
Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else
http://refi64.com

On Mar 26, 2017 9:07 AM, "Nick Coghlan" <ncogh...@gmail.com> wrote:

> On 26 March 2017 at 18:31, Victor Stinner <victor.stin...@gmail.com>
> wrote:
> > print(msg) calls sys.stdout.write(msg): write() expects text, not bytes.
> I
> > dislike the idea of putting encoding options in print. It's too specific.
> > What if tomorrow you replace print() with file.write()? Do you want to
> add
> > errors there too?
> >
> > No, it's better to write own formatter function as shown in a previous
> > email.
>
> While I agree with that, folks that are thinking in terms of errors
> handlers for str.encode may not immediately jump to using the
> `ascii()` builtin or the "%a" or "!a" format specifiers, and if you
> don't use those existing tools, you have the hassle of deciding where
> to put your custom helper function.
>
> Perhaps it would be worth noting in the table of error handlers at
> https://docs.python.org/3/library/codecs.html#error-handlers that
> backslashreplace is used by the `ascii()` builtin and the associated
> format specifiers, as well as noting the format specifiers in the
> documentation of the builtin function?
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
> _______________________________________________
> Python-ideas mailing list
> Python-ideas@python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to