[Python-3000] Displaying strings containing unicode escapes

Guido van Rossum guido at python.org
Wed Apr 30 19:34:56 CEST 2008


On Fri, Apr 18, 2008 at 7:35 PM, atsuo ishimoto <ishimoto at gembook.org> wrote:
>  - io.TextIOWrapper doesn't provide interface to change encoding
>   and error-handler after it was created. This feature is supported
>   in PEP-3116, but isn't impletented at this time. Will it be
>   implemented?

It should be implemented. It may be a little tricky if there's codec
state, but I'm okay with raising an exception in that case or doing
something else that's sensible.

>   It would be nice if we have optional encoding and errors args for print()
>   and TextIOWrapper.write(), so people can write
>   print(repr(obj), 'koi8-r', 'backslashescape').

This should be done with a new function, not added to print. Once you
specify an encoding, you have to write to sys.stdout.buffer, which is
the underlying binary stream; but you'd have to flush the
TextIOWrapper and deal with incomplete codec state, and in general I
don't think it's a good idea.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list