On 9/26/07, Alexandre Vassalotti <[EMAIL PROTECTED]> wrote: > I think indexing a bytes/buffer object should return an int. > I find this behavior more natural, to me, than using an > ord()-like function to extract values.
I didn't known about the length-1 comparison issue when I wrote this. Personally, I wouldn't mind writing either this: for b in bytes: if b == b'a'[0]: pass or this: for b in bytes: if b == b'a': pass > In fact, I remarked that the use of ord() is good indicator > that bytes should be used instead of str (look by yourself: > grep -R --include='*.py' 'ord(' python25/Lib). I don't think my argument is still valid. Compared the use of ord() in Python 2.x vs. Python 3.x with: % egrep -R --include='*.py' '\<ord\(' python/Lib | wc -l 238 % egrep -R --include='*.py' '\<ord\(' py3k/Lib | wc -l 221 I thought ord() was mostly used for extracting ints from a string object variable. I was wrong about that. ord() is most often used for getting an int value from a length-1 string constant. So, I am neutral about the whole indexing issue. Either indexing behavior has advantages and disadvantages, so it will be difficult to choose which is better. -- Alexandre _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com