Hi,

On Tuesday 18 September 2007 04:18:01 Guido van Rossum wrote:
> I'm considering the following option: bytes would always be immutable,
> (...) make b[0] return a bytes array of length 1 instead of a small int

Great idea! That will help migration from Python 2.x to Python 3.0. Choosing 
between byte and character string is already a difficult choice. So choosing 
between mutable (current bytes type) and immutable string (current str type) 
is a more difficult choice.

And substring behaviour change (python 2.x => 3) was also strange for python 
programmers.

>>> 'xyz'[0]
'x'
>>> b"xyz"[0]
120

This result is not symmetric. I would prefer what Guido proposes:

>>> 'xyz'[0]
'x'
>>> b"xyz"[0]
b'x'

And so be able to write such tests:

>>> b"xyz"[:2] == b'xy'
True
>>> b"xyz"[0:1] == b'x'
True
>>> b"xyz"[0] == b'x'
True

Victor Stinner
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