def safe_unpack(seq, ln, fill=None):
    """Safely unpack a sequence to length `ln`, without raising ValueError. Based on Lua's method of unpacking. Empty values will be filled in with `fill`, while any extra values will be cut off.
       
       :param seq: The sequence to unpack.
       
       :param ln: The expected length of the sequence.
       
       :param fill: The value to substitute if the sequence is too small. Defaults to ``None``.
       
       Example::
           
           s = 'a:b'
           a, b = safe_unpack(s.split(':'), 2)
           # a = 'a'
           # b = 'b'
           s = 'a'
           a, b = safe_unpack(s.split(':'), 2)
           # a = 'a'
           # b = None"""
    if len(seq) > ln:
        return seq[:ln]
    elif len(seq) < ln:
        return seq + type(seq)([fill] * (ln - len(seq)))
    else:
        return seq
