[Python-ideas] Add "namereplace" error handler
Steven D'Aprano
steve at pearwood.info
Tue Jun 11 15:01:31 CEST 2013
On 11/06/13 22:34, M.-A. Lemburg wrote:
>
>
> On 11.06.2013 13:21, 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?
>
> Nice idea.
>
> I think 'namereplace' is fine. An alternative would be
> 'unicodenamereplace'.
+1 on namereplace. unicodenamereplace is unnecessary, since strings in Python 3 are Unicode. Might as well say "stringnamereplace" :-)
--
Steven
More information about the Python-ideas
mailing list