On Wed, May 18, 2011 at 8:27 AM, Ethan Furman <et...@stoneleaf.us> wrote:
> 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.

No. Bytes are a list of integers between 0-256. End of story. Using
them to represent text as well was precisely the problem with 2.x
8-bit strings, since the boundaries got blurred.

However, as a matter of practicality, many byte-oriented protocols use
ASCII to make elements of the protocol readable by humans. The
"text-like" elements of the bytes and bytearray types are a concession
to the existence of those protocols. However, that doesn't make them
text - they're still binary data streams. If you want to treat them as
text, convert them to "str" objects first (e.g. that's what
urlib.urlparse does internally in order to operate on bytes and
bytearray instances).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
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