1

I want to be able to autohide code cells after they have run once in a jupyter notebook. I am calling a function that prints some output. For example

print("Hello World")

The problem I am trying to solve is that after the output is printed, the code block stays there. I can use ctrl k + ctrl o to hide the code block after execution however there are many code blocks like that and I want it to be automatic. I tried using some javascript (https://habr.com/en/post/439570/) however that didn't work as expected. I am aware that I can use NBconvert to hide all the code cells while generating a pdf however I want only some cells to be hidden and that to in the raw notebook.

I looked into how we can add metadata in the cell to hide it with python here: https://jupyterbook.org/content/metadata.html However, I want to do it locally on some cells, and I want to prevent file changed, do you want to overwrite your notebook prompts.

Is this possible?

  • refer to this : https://stackoverflow.com/questions/27934885/how-to-hide-code-from-cells-in-ipython-notebook-visualized-with-nbviewer – A DUBEY Aug 08 '21 at 13:47
  • Thanks this was useful. I tried it in the browser and this works. However this fails for VS code. – MysteriousNinja Aug 08 '21 at 13:51

1 Answers1

0

For Vscode, refer to the official documentation https://code.visualstudio.com/docs/datascience/jupyter-notebooks, however I couldn't find anything related to autohide/collapse when using Vscode. They might release this functionality in their next release.

A DUBEY
  • 806
  • 6
  • 20