def _FormatConstraint(RelDict, RelVal):
    """Formats a Constraint or Function for use in a convenient way"""
    linelen = 45
    s = ['']
    for var, val in RelDict.items():
        if var.startswith('_'):
            continue
        if len(s[-1]) > linelen:
            s.append(' ')
        m = val
        if s[-1] != '' and m >= 0:
            s[-1] += ' + '
        elif s[-1] != '':
            s[-1] += ' - '
            m = abs(m)
        s[-1] += '%.3f*%s ' % (m, var)
    if len(s[-1]) > linelen:
        s.append(' ')
    if RelVal is None:
        s[-1] += ' = New variable'
    else:
        s[-1] += ' = ' + RelVal
    s1 = ''
    for s2 in s:
        if s1 != '':
            s1 += '\n\t'
        s1 += s2
    return s1
