[Python-ideas] Adding an 'errors' argument to print
Michel Desmoulin
desmoulinmichel at gmail.com
Sat Mar 25 15:49:48 EDT 2017
Le 24/03/2017 à 17:37, Victor Stinner a écrit :
> *If* we change something, I would prefer to modify sys.stdout. The
> following issue proposes to add
> sys.stdout.set_encoding(errors='replace'):
> http://bugs.python.org/issue15216
>
> You can already set the PYTHONIOENCODING environment variable to
> ":replace" to use "replace" on sys.stdout (and sys.stderr).
>
> Victor
This is not the same. You may want to locally apply "errors=replace" and
not the whole program.
Indeed, this can silence encoding problems. So I would probably never
set in to errors at dev time except for the few places where I know I
can explicitly silence errors.
I quite like this print(errors="replace|ignore"). This is not going to
cause any trouble, and can only help.
More information about the Python-ideas
mailing list