Ask Your Question

Revision history [back]

You can try the sage_input function:

sage: m = matrix(QQ, [[1,2,3], [4,5,6], [7,8,9]])
sage: m
[1 2 3]
[4 5 6]
[7 8 9]
sage: sage_input(m)
matrix(QQ, [[1, 2, 3], [4, 5, 6], [7, 8, 9]])

Save the last line to a file instead of just

[1 2 3]
[4 5 6]
[7 8 9]

The sage_input function is documented here