Why does unicode-escape decode escape symbols that are already escaped?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Mon May 11 00:00:16 EDT 2015


On Mon, 11 May 2015 03:00 am, Terry Reedy wrote:

> Decoding a string only makes sense for rot-13

Or any other string-to-string encoding.

As has been discussed on python-ideas and python-dev many times, the idea of
a codec is much more general than just bytes -> string and string -> bytes.
It can deal with any transformation of data. The codec machinery can, I
believe, operate on any suitable type, and it can certainly operate on
bytes -> bytes and str -> str.


I have gradually come to agree that bytes and str objects should only
support decode() and encode() operations respectively, but str->str and
bytes->bytes codecs are useful to.


-- 
Steven




More information about the Python-list mailing list