I\'d like to convert a hex triplet to an RGB tuple and then convert a tuple to a hex triplet.
Trying to be pythonic:
>>> rgbstr='aabbcc' >>> tuple(ord(c) for c in rgbstr.decode('hex')) (170, 187, 204) >>> tuple(map(ord, rgbstr.decode('hex')) (170, 187, 204)
and
>>> rgb=(12,50,100) >>> "".join(map(chr, rgb)).encode('hex') '0c3264'