
On May 17, 2011, at 5:27 PM, Ethan Furman wrote:
The bytes type in Python 3 does not feel very consistent.
For example:
--> some_var = 'abcdef' --> some_var 'abcdef' --> some_var[3] 'd' --> some_other_var = b'abcdef' --> some_other_var b'abcdef' --> some_other_var[3] 100
On the one hand we have the 'bytes are ascii data' type interface,
This is incidental. Bytes can and often do contain data with non-ascii encoded text, plain binary data, or structs, or raw data read off a disk, etc.
and on the other we have the 'bytes are a list of integers between 0 - 256' interface. And trying to use the two is not intuitive:
--> some_other_var[3] == b'd' False
When I'm parsing a .dbf file and extracting field types from the byte stream, I'm not thinking, "okay, 67 is a Character field" -- what I'm thinking is, "b'C' is a Character field".
Considering that ord() still works fine, I'm not sure why it was done this way.
Is there code out there that is using this "list of int's" interface,
Yes.
or is there time to make changes to bytes?
No. Raymond