Why Does No Python-Tutorial Mention Jupyter? What?

Why Does No Python-Tutorial Mention Jupyter? What?

Jupyter Notebooks or Jupyter-like code-cells make life so much easier

I have been trying a lot of free Python tutorials before sticking to one paid version. But it needed a person who worked in tech to tell me that Jupyter Notebooks exist and that they can make the life of someone who is new to Python, so much easier. This should be part of every tutorial!

Since I am not an expert, let me very amateurish explain that concept to you. I do not in any way guarantee it being complete! With Jupyter you can basically create a documentation file with executable python code in it. Your file is split up in different cells and those cells can contain basically everything you need for explaining, visualizing, and running your code. It's far beyond #-comments in your code. You can write articles with executable code in them. But you can also do another thing. You can experiment with how your code works. You can even choose to not run certain parts of your code to try different ways without having to comment out code parts. It's an amazing way to experiment, learn, analyze and mentally organize your code.

How Do I Try This?

# %%
msg = "Hello World"
print(msg)

# %%
msg = "Hello again"
print(msg)

Writing # %% into VSCode will create the beginning of a cell above your code. It will look something like this in your Editor.

jupyter.jpg

You can now treat each cell independently if you chose to. You can also still run the whole code normally. Running cells will open an interactive IPython window in VSCode. In that you see the results of your code, you can also type in code to further test and try. For a fact, most of the experiments in the Cat-Algorithm Project were done with Jupyter-Elements in the Python-File.

catjupyter.jpg

Tutorials Should Talk About This

Testing, understanding, experimenting with code is so much more convenient like this. Tutorials should talk about it. Sure maybe not in the first lesson but once they are through the rough basics, a small "Oh by the way this is a neat way to test and document your code" would be pretty amazing. This might be old news for people following the development of Python over the years, but for beginners - this is not mentioned anywhere unless someone points it out to you.

The only down sight to this, that I found was that PyCharm does not support # %% natively but requires you to use the paid version. But in that case, you could also hop over to Google Colab and use their browser version or use VSCode.

For anyone else learning Python - try it out. You'd be surprised how much it helps your understanding of your code.

 
Share this