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, 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, or is there time to make changes to bytes?

~Ethan~
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to