1

Proof

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?

mathguy
  • 1,450
  • 1
  • 16
  • 33

1 Answers1

2

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 an Out[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.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • Thanks for your reply. I guess I have to stick with using logging module for efficient logging for a while now, since ipython does not quite support what I intended to do. – mathguy Jun 29 '19 at 16:52
  • Ok, I understand. Sorry my advice was not helpful to you. – Carlos Cordoba Jun 29 '19 at 18:32