ubsuny / CP1-24-HW3

Homework 3 template for CP1-24
1 stars 16 forks source link

Jupyter Notebooks (& Google Collab) vs traditional Python files #57

Closed avgagliardo closed 1 week ago

avgagliardo commented 1 week ago

I am seeing a little bit of confusion from people working across different types of development environments. Whether its a jupyter notebook, a google collab workspace, or normal .py python files in the codespace (or on a local machine). I wanted to help clarify things a little bit for the future.

We've gone over it a few times in class, but maybe this summary will help people decide on which env/workspace they would prefer to use for specific tasks.

Normal Python Files (.py)

Format: Plain text files that contain Python code, which are executed as scripts. Environment: Can be run from any Python environment (terminal, IDEs, VS Code like our codespace.). Version Control: Easy to use with Git and other version control systems because it’s pure code with no additional formatting.

Best For:

Jupyter Notebooks (.ipynb)

Format: A web-based interactive document that combines code cells, Markdown, and rich media (plots, images, LaTeX, etc.). Environment: Can be run locally using the Jupyter environment or through other services like Anaconda or within a Github codespace environment. Version Control: Not as easy to manage due to the binary nature of the notebook file (harder to track diffs in code compared to plain .py files).

Best For:

Google Colab

Format: Essentially an online version of Jupyter Notebooks hosted by Google. Environment: Cloud-based, runs on Google’s infrastructure limited access to the backend configurations and running processes. Version Control: Similar to Jupyter, though Google Colab integrates poorly with traditional version control (like git/github) and instead is designed to interface with with Google Drive, making it easier to save and share like conventional (non-code) files.

Best For:

In Conclusion:

Notebooks are great for "exploratory" coding, but they end up producing files that make it difficult to share, test, and maintain your code unless you are willing to convert them to .py files at some point in your development cycle.

It should be noted that the conversion process is not especially difficult or laborious, but it should be a deliberate shift that happens because if you wait until the end to convert all of your files then you will most likely need to change part of your program's structure or runtime, which can become nontrivial.