class Matrix: def __init__(self, rows, cols): self.rows = rows self.cols = cols def __str__(self): return "rows {}, cols {}".format(self.rows, self.cols) m = Matrix(2, 3) print(m); # outputs: rows 2, cols 3