[Python-ideas] Add "namereplace" error handler

Ethan Furman ethan at stoneleaf.us
Tue Jun 11 18:17:27 CEST 2013


On 06/11/2013 04:21 AM, Serhiy Storchaka wrote:
> I propose to add "namereplace" error handler which is similar to "backslashreplace" error handler but use \N escapes
> instead of \x/\u/\U escapes.
>
>>>> '−1'.encode('ascii', 'backslashreplace')
> b'\\u22121'
>>>> '−1'.encode('ascii', 'namereplace')
> b'\\N{MINUS SIGN}1'
>
> In some cases such representation is more readable.
>
> What are you think about this? Are there suggestions for better name?

+1 for the idea and the name

--
~Ethan~


More information about the Python-ideas mailing list