Strange extra f added to bytes object

Robert Jackson rhjacksoniii at gmail.com
Sun Oct 6 21:38:27 EDT 2013


Thank you all.  It was unfortunate that it was f since I thought it was
some strange mistaken hex nibble.  All very clear and helpful.



On Sun, Oct 6, 2013 at 9:07 PM, Steven D'Aprano <
steve+comp.lang.python at pearwood.info> wrote:

> On Sun, 06 Oct 2013 20:39:39 -0400, Ned Batchelder wrote:
>
> > When Python displays a string, is uses
>
> A byte string.
>
> > the ASCII character if it can, and a hex escape if it can't.  When you
> > use a hex value that is a valid ASCII character, it will display the
> > character.
>
> Obviously for Python 2 that behaviour can't change, but I am saddened
> that the opportunity to fix the display of byte strings in Python 3
> wasn't taken. In my opinion, it would have been much better if byte
> strings were always shown in hex. (They could also have a separate method
> for showing them in ASCII, if necessary, but even that is only one call
> to decode() away.)
>
> Displaying a *byte* string using ASCII by default just continues the
> confusion that many people have, that the character "f" is necessarily
> the same as the byte 0x66. *And* it leads to the OP's error, wondering
> why his byte-stream of 0x66... displays with a strange 'f'.
>
> If you ask me, including ASCII in the printable representation of byte
> strings in Python 3 is buggy by design :-(
>
>
> --
> Steven
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131006/cd360926/attachment.html>


More information about the Python-list mailing list