Ah, the majestic Jupyter notebook. The python programming method that we all love to hate. For the unfamiliar, Jupyter notebooks are a python programming method that allows you to program and run python code in separate cells as you program. There is a benefit to this for, say, doing math, since you can assign variables once and run the calculations in a separate block of code. This prevents the user from needing to run the code in a terminal or IDE and rerun the assignment of variables. You can also see line by line what each function is outputting by simply writing the variable name you want to output as another line. In this way it's very similar to a debugger where you can stop the code at certain points and see the output as the code is executing.
If you've never needed to use Jupyter notebooks before, this probably sounds all well and good. It is, but anyone who has ever needed to use the Jupyter notebook for a math class using Sympy or Numpy knows the frustration of opening up a notebook and spending 10-15 minutes (or longer, no judgments here) trying to figure out why the code won't work only to see that you forgot to execute the first block of code where the libraries are imported. And you'll have to run every block of code in chronological order as soon as you open the notebook, or else it simply won't work. None of the viewers for notebooks will run the code once you open it, to avoid overusing disk space and RAM, I suppose including the semi-popular viewer Anaconda, Google Colab, and Visual Studio. It would also be very easy with this feature set on to turn python notebooks into a vehicle for viruses and trojans. If Tom Scott's Youtube channel has taught me anything, however, it's to be afraid of every threat and possibility of error from all angles when coding.
Python notebooks can be a powerful tool as shown by the version of AI Dungeon 2 that can be run in a notebook. I've been thinking a lot recently about python code that I have interacted with and wondering if it can be run as a more modular, modifiable code in a Jupyter notebook. One example is the weekly playlist code that Ben has been working on for a while now. The code removes songs from an old playlist and adds the new songs, as well as changing the name. It might not be possible to write the code in a notebook due to the process of downloading the Spotipy library, but if it were, you could run the code in steps to make sure that each step of the process had properly finished before beginning the next part of the process. I may post on here the version that Ben has written currently with edits alongside a version in a Jupyter notebook format. It's just an interesting concept overall, and I think that this format should be considered by hobbyists for applications in the future just to see how far we can push the limits of the format.
No comments:
Post a Comment