Bryan Olson wrote:
Python 3 has the 'bytes' type, which the string type I've long wanted in
various languages. Among other advantages, it is immutable, and
therefore bytes objects can be dict keys. There's a mutable version too,
called "bytearray".
In Python 2.6, the name 'bytes' is defined, and bound to str. The 2.6
assignment presents some pitfalls. Be aware.
[...]
I'm thinking I should just avoid using 'bytes' in Python 2.6. If there's
another Python release between 2.6 and 3.gold, I'd advocate removing
the pre-defined 'bytes', or maybe defining it as something else.
I guess you got the intention of the bytes alias wrong. It's partly my
fault because I didn't document the bytes alias. We are well aware that
the bytes alias in 2.6 isn't fully compatible with the bytes type in
3.0. The bytes alias isn't MEANT to be compatible, too. :)
At first I wanted to backport the bytes type from 3.0 to 2.6. But it was
too many work and the implications of yet another types were too
complex. So I just added the alias in order to help people with writing
forward compatible code like e.g. isinstance(egg, bytes).
Summa summarum the bytes alias serves was added for documentary purpose
and to aid the 2to3 transition of code where 'str' is ambiguous.
Christian
--
http://mail.python.org/mailman/listinfo/python-list