Issue
I followed this post which led me to this post in order to save ipython's input results(not to be confused input results with outputs; they are considered different things in ipython). The post's accepted answer is simply 'use %logstart -o
in the ipython' and I follow the answer wholeheartedly, expecting it to work, but it does not.
Since a picture is worth more than a thousand words, I here present the picture that shows %logstart -o
cannot solve my problem. The picture clearly shows that I used %logstart -o
in the ipython and I played a file that prints a string and a numpy array. The string and the array do not show up in the ipython_log.py, which concludes either of two things.
1) %logstart -o
is bugged(which I do not believe)
2) %logstart -o
works but it does not accomplish my goal
My question is the following:
If %logstart -o
cannot accomplish my goal, then what can?
Solution
The documentation is quite clear on the second post you referenced, but let me quote the important part for you:
In this mode [i.e., the
%logstart
mode], all commands which generate anOut[NN]
prompt are recorded to the logfile
Given that you're using runfile
to run your code, not Out[NN]
prompts will be generated and you have to use print
statements instead to see your results (which can't be logged with %logstart
).
So my only advice for you is to not use runfile
, but to instead use cells, which are sections of code separated by comments of the form # %%
and that you can run with Shift+Enter
. That's equivalent to run your code directly in the console, which should generate the necessary Out[NN]
prompts.
Other than that, I think it's not possible to get what you want, sorry.
Answered By - Carlos Cordoba
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.