I am looking for a more elegant solution to formatting a MAC address with colons. I am using Python 3.2. A fancy list comprehension perhaps?
s=\"\"
h=\"0023
Not new but still most elegant I think:
import re
':'.join(re.findall('..', '08002714f616'))
>>> import itertools
>>> h = '00233a990c21'
>>> ':'.join(a+b for a, b in (itertools.izip(
... itertools.compress(h, itertools.cycle((1,0))),
... itertools.compress(h, itertools.cycle((0,1))))))
>>> '00:23:3a:99:0c:21'
Does that win for the highest density of parentheses?