[Python-Dev] bytes type discussion (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Wed Feb 15 09:03:49 CET 2006
- Previous message: [Python-Dev] bytes type discussion
- Next message: [Python-Dev] bytes type discussion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Adam Olsen wrote:
My assumption is these would become errors in 3.x. bytes(str) is only needed so you can do bytes(u"abc".encode('utf-8')) and have it work in 2.x and 3.x.
I think the proposal for bytes(seq) to mean bytes(map(ord, seq)) was meant to be valid for both 2.x and 3.x, on the grounds that you should be able to write byte string constants in the same way in all versions.
(I wonder if maybe they should be an error in 2.x as well. Source encoding is for unicode literals, not str literals.)
Source encoding applies to the entire source code, including (byte) string literals, comments, identifiers, and keywords. IOW, if you declare your source encoding is utf-8, the keyword "print" must be represented with the bytes that represent the Unicode letters for "p","r","i","n", and "t" in UTF-8.
Regards, Martin
- Previous message: [Python-Dev] bytes type discussion
- Next message: [Python-Dev] bytes type discussion
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]