def center_text(text, length=80, left_edge='|', right_edge='|',
                text_length=None):
    """Center text with specified edge chars.

    You can pass in the length of the text as an arg, otherwise it is computed
    automatically for you.  This can allow you to center a string not based
    on it's literal length (useful if you're using ANSI codes).
    """
    # postcondition: len(returned_text) == length
    if text_length is None:
        text_length = len(text)
    output = []
    char_start = (length // 2) - (text_length // 2) - 1
    output.append(left_edge + ' ' * char_start + text)
    length_so_far = len(left_edge) + char_start + text_length
    right_side_spaces = length - length_so_far - len(right_edge)
    output.append(' ' * right_side_spaces)
    output.append(right_edge)
    final = ''.join(output)
    return final
dataset/ETHPy150Open aws/aws-cli/awscli/table.py/center_text/swapped operands of `-`