def seg_str(seg, seg_term, ele_term, subele_term, eol=''):
    """
    Join a list of elements
    @param seg: List of elements
    @type seg: list[string|list[string]]
    @param seg_term: Segment terminator character
    @type seg_term: string
    @param ele_term: Element terminator character
    @type ele_term: string
    @param subele_term: Sub-element terminator character
    @type subele_term: string
    @param eol: End of line character
    @type eol: string
    @return: formatted segment
    @rtype: string
    """
    tmp = []
    for a in seg:
        if type(a) is list:
            tmp.append(subele_term.join(a))
        else:
            tmp.append(a)
    return '%s%s%s' % (ele_term.join(tmp), seg_term, eol)
