Forums

How to prevent Ipython console from clearing shown text after closing?

For example: I open the IPython3.9 console and do the following:

run example.py
example_var = 'example value'
class_instance = Class(.......)

Now the code starts running and the console prints out text:

Printed out text 1
Printed out text 2
Printed out text 3

I close the browser tab in which the console is running (I don't close the console itself). And then I reopen it. Now I only see the following, without being able to scroll up and seeing all the previous inputs, outputs (prints) of the console:

Printed out text 5 
(here the script keeps running)

So how do I prevent this from happening so I can see everything that's I have written and everything that the console printed out even after closing the browser console tab, like for example:

run example.py
example_var = 'example value'
class_instance = Class(.......)
Printed out text 1
Printed out text 2
Printed out text 3
Printed out text 4 
Printed out text 5
....

Is it possible? Thank you a lot in advance and sorry if it's a stupid question (it's my first time ever using a service like pythonanywhere).

ps: I have the "Hacker" plan

In general, the output that it has previously displayed in an ipython console will still be there when you reconnect and you will be able to scroll back to it. If you're doing something with xterm control codes that clears output on the same line, then it's possible that that would be removing the lines that you are expecting to be there.

EDIT: the problem persists even without using the alive-progress library. Here are 3 images, before closing the console tab and after reopening it:

before closing the console tab (2 images, when everything the console prints out remains viewable by scrolling up):

when loop stops printing: https://ibb.co/xJrrjVd and when I scroll up: https://ibb.co/tC1cWjq

after closing it when I reopen the tab:

https://ibb.co/jyhQ02D Note that scrolling up to the start is impossible

I don't think I am doing anything with xterm control codes, because I don't even know what they are, but thanks anyway for the heads up :)

Ah, OK -- I think my colleague didn't quite understand what you meant. We only cache a limited amount of the output that your script has printed on the server side -- in general about 500 lines, though that can be higher or lower depending on those control codes that Glenn mentioned, and various other factors. So if you refresh the page you will lose all but the last ~500 lines.

So that's what happens.

Thank you so much for the quick replies. That being the case I think I'll manage to sort something out! Thank you again.

No problem! Glad to help.