[Python-ideas] Adding an 'errors' argument to print
Steve Dower
steve.dower at python.org
Sun Mar 26 23:10:58 EDT 2017
On 26Mar2017 0707, Nick Coghlan wrote:
> 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
backslashreplace is also the default errors for stderr, which is
arguably the right target for debugging output. Perhaps what we really
want is a shorter way to send output to stderr? Though I guess it's an
easy to invent one-liner, once you know about the difference:
>>> printe = partial(print, file=sys.stderr)
Also worth noting that Python 3.6 supports Unicode characters on the
console by default on Windows. So unless sys.stdout was manually
constructed (a possibility, given this was a GUI app, though I designed
the change such that `open("CON", "w")` would get it right), there
wouldn't have been an encoding issue in the first place.
Cheers,
Steve
More information about the Python-ideas
mailing list