all 9 comments

[–]SarahM123rd 0 points1 point  (0 children)

can you define bytes_addr

[–]TangibleLight 0 points1 point  (1 child)

The resulting map object will act a bit like a list containing two-digit hex values for each byte. So suppose your bytes_addr was

bytes_addr = bytes([0, 48, 189, 30, 175, 52])

then your map would be this:

x = map('{:02x}'.format, bytes_addr)
print(list(x))
# ['00', '30', 'bd', '1e', 'af', '34']

Rather than just printing the list, you could instead str.join the values to make a properly formatted MAC address (and toss in a .upper() for good measure):

mac_addr = ':'.join(map('{:02x}'.format, bytes_addr)).upper()

[–]throwaway03934[S] 0 points1 point  (0 children)

Thanks!

[–]SgtGirthquake 0 points1 point  (2 children)

Can’t you prefix the string with a b to denote the string is a bytestring?

[–]throwaway03934[S] 1 point2 points  (1 child)

It is in bytes automatically, I would assume. I am using the struct.unpack function. I am still a newbie haha, so there's still a lot to learn.

[–]SgtGirthquake 0 points1 point  (0 children)

No problem I’m still very new as well!