def __str__(self):
        """'Pretty' formatting of the Matrix44."""

        # Pretty printing generates a lot of ugly code - oh the irony!
        # Changed in release 0.0.3 so that the decimal point is always
        # line up on the columns

        cols = [ list(map(format_number, col)) for col in self.columns() ]

        def decimal_pos(n):
            if '.' in n:
                return n.index('.')
            return len(n)

        for col_no, col in enumerate(cols[:]):

            decimal = max( decimal_pos(format_number(c)) for c in col )
            cols[col_no] = [" "*(decimal-decimal_pos(c))+c for c in col]

        max_col_lengths = [ max(len(c) for c in col) for col in cols ]
        rows = [[], [], [], []]
        for row_no in range(4):

            for col_no in range(4):

                v = cols[col_no][row_no]
                rows[row_no].append( v.ljust(max_col_lengths[col_no]) )

        rows = [" ".join(row).rstrip() for row in rows]
        return "\n".join("[ %s ]"%row for row in rows)

        return str(cols)
dataset/ETHPy150Open PythonProgramming/Beginning-Game-Development-with-Python-and-Pygame/Chapter 10/gameobjects/matrix44.py/Matrix44.__str__/original