Ask Your Question

Revision history [back]

Your question is not very clear. If you want to save the output in a text file named /tmp/file.py, you can do:

sage: with open('/tmp/file.py','w') as f:
....:     f.write(str(sage_input(m)))

If you want to append to an existing file, just replace 'w' with 'a'.

Your question is not very clear. clear on where to copy the code.

If you want to save the output in a text file named /tmp/file.py, you can do:

sage: with open('/tmp/file.py','w') as f:
....:     f.write(str(sage_input(m)))

If you want to append to an existing file, just replace 'w' with 'a'.

If you want to copy the output in the clipboard so that you can paste it from the mouse to some window with CTRL+V, you can install clipboard Python module from a shell:

$ sage -pip install clipboard

an then do (in the Sage session):

sage: import clipboard
sage: clipboard.copy(str(sage_input(m)))

Your question is not very clear on where to copy the code.

If you want to save the output in a text file named /tmp/file.py, you can do:

sage: m = random_matrix(ZZ,100,100)
sage: with open('/tmp/file.py','w') as f:
....:     f.write(str(sage_input(m)))

If you want to append to an existing file, just replace 'w' with 'a'.

If you want to copy the output in the clipboard so that you can paste it from the mouse to some window with CTRL+V, you can install clipboard Python module from a shell:

$ sage -pip install clipboard

an then do (in the Sage session):

sage: import clipboard
sage: clipboard.copy(str(sage_input(m)))

Your question is not very clear on where to copy the code.

If you want to save the output in a text file named /tmp/file.py, you can do:

sage: m = random_matrix(ZZ,100,100)
sage: with open('/tmp/file.py','w') as f:
....:     f.write(str(sage_input(m)))

If you want to append to an existing file, just replace 'w' with 'a'.

If you want to copy the output in the clipboard so that you can paste it from the mouse to some window with CTRL+V, you can install clipboard Python module within Sage virtual environment from a shell:

$ sage -pip install clipboard

an then do (in the Sage session):

sage: import clipboard
sage: clipboard.copy(str(sage_input(m)))