def split_in_pairs(s, padding = "0"):
    """
    Takes a string and splits into an iterable of strings of two characters each.

    Made to break up a hex string into octets, so default is to pad an odd length
    string with a 0 in front. An alternative character may be specified as the
    second argument.
    """
    if not isinstance(padding, str) or len(padding) != 1:
        raise TypeError("Padding must be a single character.")

    s = padding + s if len(s) % 2 else s
    v = iter(s)
    return (a+b for a,b in zip(v,v))