Is it possible to have new printouts at top of cell?

Let’s say I have a cell where I execute the following code:

for n in range(5):
    print(n)

You would expect to see the following printout to console below the cell:

0
1
2
3
4

Sometimes the number of lines printed can be quite lengthy, and it’s rather annoying to have to scroll down to the bottom of the cell to see what’s going on. Is it possible to modify some setting so that new lines are printed at the top rather than the bottom? Let’s say each line is a string inside of a list, you could simply reverse that list, or prepend to it every time there is a new line to be printed. Is this a possibility?

This doesn’t do exactly what you want with new output being at the top in the way you describe, however, it gives you some options…
With JupyterLab you can open the console and enable Show all kernel activity and the most current output from your cell will be stuck to the bottom of the console. It will look similar to this video where the top of the map is seen in the upper view and the bottom is ‘stuck’ to the bottom panel. I tested a larger range than in your demo code and it works. I describe how to do that in detail here because it has changed since that video was made.

If you want the console to be on the top, you can drag it’s tab up above the notebook to rearrange the two windows so that technically it shows the new output on the top in a manner of speaking. The rearranged version looks like this:



Plus, to save scrolling in the classic notebook interface, I note there is the Scroll Down extension. You can find more information about those extensions here. You may have already installed the community-contributed unofficial extensions and just need to enable the particular one. The configuration dashboard shown towards the bottom of the page here is convenient for that.

1 Like