[Python-ideas] Adding 'bytes' as alias for 'latin_1' codec.

Greg Ewing greg.ewing at canterbury.ac.nz
Sat May 28 04:00:13 CEST 2011


Nick Coghlan wrote:

> Perhaps it is time to resurrect the idea of an explicit 'ascii' type?
> Add a'' literals, support the full string API as well as the bytes
> API, deprecate all string APIs on bytes and bytearray objects.

That sounds like an idea worth pursuing. Maybe also introduce an
x'...' literal for bytes at the same time, with a view to eventually
deprecating and removing the b'...' syntax.

I don't think I would remove *all* the string methods from bytes,
only the ones that assume ascii encoding. Searching and replacing
substrings etc. still makes sense on arbitrary bytes.

How would ascii behave when mixed with unicode strings? Should it
automatically coerce to unicode, or should an explicit decode()
be required?

-- 
Greg



More information about the Python-ideas mailing list