help understanding print out of Message data attribute bytearray

Issue #87 closed
Mike Molt created an issue
m1 = Message(timestamp=1464272050.013290,
             arbitration_id=0x0000ff00,
             data=[0x30,0x00,0xff,0xff,0xff,0xff,0xff,0xff]
             )
print(m1.data)

...but I get this when I print the data attribute...why?

bytearray(b'0\x00\xff\xff\xff\xff\xff\xff')

Comments (3)

  1. Brian Thorne repo owner

    So Python displays the bytearray using ascii where it can. It happens that 0x00 and 0xff have no ascii equivalent so they are shown as \x00 and \xff, 0x30 however is the ascii encoding of 0 (and 0x31 is 1)

    :-)

  2. Mike Molt reporter

    Awesome, thank you Brian...I was hoping it would be something like this!

    Sorry for the noobish question.

  3. Log in to comment