def slices(s, slicing):
    """
    Slice object into segments of given length.

    e.g. slices("001007",[1,2,3]) => ["0","01","007"]
    """
    position = 0
    out = []
    for length in slicing:
        out.append(s[position:position + length])
        position += length
    return out
