Python. Print mac address out of 6 byte string

import struct
"%x:%x:%x:%x:%x:%x" % struct.unpack("BBBBBB",your_variable_with_mac)

There's no need to use struct:

def prettify(mac_string):
    return ':'.join('%02x' % ord(b) for b in mac_string)

Although if mac_string is a bytearray (or bytes in Python 3), which is a more natural choice than a string given the nature of the data, then you also won't need the ord function.

Example usage:

>>> prettify(b'5e\x21\x00r3')
'35:65:21:00:72:33'

Try,

for b in addr:
    print("%02x:" % (b))

Where addr is your byte array.