
May 28, 2011
4 a.m.
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