Strange extra f added to bytes object

Joel Goldstick joel.goldstick at gmail.com
Sun Oct 6 20:41:52 EDT 2013


On Sun, Oct 6, 2013 at 8:38 PM, MRAB <python at mrabarnett.plus.com> wrote:
> On 06/10/2013 23:47, Robert Jackson wrote:
>>
>> I am very new to python so I'll apologize up front if this is some
>> boneheaded thing.  I am using python and pyserial to talk to an embedded
>> pic processor in a piece of scientific equipment.  I sometimes find the
>> when I construct the bytes object to write it adds an extra f to the
>> first byte.
>>
>> For example if I have b'\x03\x66\x02\x01\xaa\xbb' it evaluates
>> to b'\x03f\x02\x01\xaa\xbb', which doesn't even seem valid.
>>
>> Can anyone shine some light this?
>>
>>>> b'\x66' == b'f'
> True
>
> Python always prints a bytestring the same way. It doesn't 'remember'
> how it was originally created.
>
> Another example:
>
>>>> b'\x68\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64'
> b'hello world'

ah, now I see ascii 'f' = \x66    that's a double take!
>
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com



More information about the Python-list mailing list