I have a Python script:
x=1.
x
and I would like to generate the following text from the command line:
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> x=1.
>>> x
1.0
and save it into a file.
This is the content that I can get by interactively copying and pasting the code into the Python interpreter.
I considered the following messages :
- How to save a Python interactive session? but this shows how to save the Python statements, not the output in the console.
- How can I save all the variables in the current python session? but this shows how to save the variables, not the content of the session.
- how to save python session input and output is exactly what I want, but has no answer.
I considered
- using IPython and the "%save" magic, but this only saves the Python statements, not the output of the statements,
- using Jupyter Notebook, but the exports are in PDF, tex, HTML, etc... while I only want plain text.
Any help will be very appreciated.