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

Ethan Furman ethan at stoneleaf.us
Sat May 28 04:23:43 CEST 2011


Greg Ewing wrote:
> 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?

And what happens when a char > 127 hits the ascii stream?

As for unicode interoperation, I'm inclined to let it be implicit, since 
ascii directly overlaps unicode.  Depending, of course, on the answer to 
the above question.

~Ethan~



More information about the Python-ideas mailing list