'Return the Matrix as a nested Python list.
Examples
>>> from sympy import Matrix, ones
>>> m = Matrix(3, 3, range(9))
>>> m
Matrix([
[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
>>> m.tolist()
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]
>>> ones(3, 0).tolist()
When there are no rows then it will not be possible to tell how
many columns were in the original matrix:
>>> ones(0, 3).tolist()'

def tolist(self):

    if (not self.rows):
        return []
    if (not self.cols):
        return [[] for i in range(self.rows)]
    return self._eval_tolist()
