(sign, body, spec)
return result
Given an unpadded, non-aligned numeric string 'body' and sign
    string 'sign', add padding and alignment conforming to the given
    format specifier dictionary 'spec' (as produced by
    parse_format_specifier).

    Also converts result to unicode if necessary.
Given an unpadded, non-aligned numeric string 'body' and sign
    string 'sign', add padding and alignment conforming to the given
    format specifier dictionary 'spec' (as produced by
    parse_format_specifier).
Given an unpadded non - aligned numeric string body and sign string sign add padding and alignment conforming to the given format specifier dictionary spec ( as produced by parse_format_specifier ) .
def _format_align(sign, body, spec):
    """Given an unpadded, non-aligned numeric string 'body' and sign
    string 'sign', add padding and alignment conforming to the given
    format specifier dictionary 'spec' (as produced by
    parse_format_specifier).

    Also converts result to unicode if necessary.

    """
    # how much extra space do we have to play with?
    minimumwidth = spec['minimumwidth']
    fill = spec['fill']
    padding = fill*(minimumwidth - len(sign) - len(body))

    align = spec['align']
    if align == '<':
        result = sign + body + padding
    elif align == '>':
        result = padding + sign + body
    elif align == '=':
        result = sign + padding + body
    elif align == '^':
        half = len(padding)//2
        result = padding[:half] + sign + body + padding[half:]
    else:
        raise ValueError('Unrecognised alignment field')

    # make sure that result is unicode if necessary
    if spec['unicode']:
        result = unicode(result)

    return result
def _format_align ( sign , body , spec ) : # how much extra space do we have to play with? minimumwidth = spec [ 'minimumwidth' ] fill = spec [ 'fill' ] padding = fill * ( minimumwidth - len ( sign ) - len ( body ) ) align = spec [ 'align' ] if align == '<' : result = sign + body + padding elif align == '>' : result = padding + sign + body elif align == '=' : result = sign + padding + body elif align == '^' : half = len ( padding ) // 2 result = padding [ : half ] + sign + body + padding [ half : ] else : raise ValueError ( 'Unrecognised alignment field' ) # make sure that result is unicode if necessary if spec [ 'unicode' ] : result = unicode ( result ) return result