On Sunday 12 August 2007 19:11:18 Bill Janssen wrote:
> Why not just write
>
>    b'xyz'[0:1] == b'x'

It's just strange to write:
   'abc'[0] == 'a'
for character string and:
   b'abc'[0:1] == b'a'
for byte string.

The problem in my brain is that str is a special case since a str item is also 
a string, where a bytes item is an integer.

It's clear that "[5, 9, 10][0] == [5]" is wrong, but for bytes and str it's 
not intuitive because of b'...' syntax. If I had to wrote [120, 121, 122] 
instead of b'xyz' it would be easier to understand that first value is an 
integer and not the *letter* X or the *string* X.


I dislike b'xyz'[0:1] == b'x' since I want to check first item and not to 
compare substrings.

Victor Stinner aka haypo
http://hachoir.org/
_______________________________________________
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

Reply via email to