Which is better for Python Programming?

There are many applications in which you can run your Python codes. We have what we called Notebooks and Integrated Development Environment or IDE.

Notebooks are files which supports the use of computer codes and text elements and images. IDEs on the other hand are software for building applications with the different tools for writing a program such as source code editor and code debugger.

Google Colab and Jupyter are examples of Notebooks. Files in these applications are saved as .ipynb as default. On the other hand, there are many IDE available such as PyCharm, Spyder and PyDev. Files in these applications are saved as .py as default.

In building a Python program, which one should we use? What are the key differences and similarities of a notebook and an IDE? In this case we will only look at Google Colab and Spyder.

Colab runs on cloud, Spyder runs on your computer

Colab gives you an allocated GPU for free. Google will lend you upto 12GB RAM and 50GB hard drive space. You can see it in the upper right corner of the Colab window. Unlike Spyder that runs on your computer.

Colab is also directly connected to GitHub and Google Drive. It will be easier to manage notebooks in the cloud without saving the files into your machine. And my favorite would be there is an auto-save function for Colab while Spyder does not have (reminder to press Ctrl+S now, kidding) There is also a feature in Colab in which the notebook can be easily saved in your GitHub repository.

If you build your codes in Spyder, you have to upload file in GitHub through the Add file button or through command prompt.

Click here for a more detailed tutorial for using GitHub.

Documentation in Colab is easier than Spyder

If you are building a program as a team, a notebook might be more useful than an IDE.

Notebooks, Colab in particular, facilitates documentation by allowing users to put texts and images and it also has an edit history which are not supported in Spyder. We can only put comments in Spyder e.g. #Give the user some context

Colab also lets programmers create sections for their codes and display output for each section. This is useful in creating long programs because output for a line is separated for the output of another line.

Unlike in Spyder, the output for all the lines will be saved in the console or prompt.

Access for saved objects and data is easier in Spyder than Colab

If you want to see the data or objects saved in your program, Spyder has a specific window for that: Variable Explorer. In this window, all objects and data in your program are listed with their corresponding type, size and value.

We can also look into each data to have a full picture of what it looks like. You can also make changes on that object in this window.

However, this is not possible in Colab. There is no list of variables or objects saved in the program and the only way we can see the full picture of data is by printing e.g. print(questions). This may be a bit of a hassle for some because sometimes we only want to know what the data looks like but we don’t intend to print it or include it in our outputs.

Notebooks and IDEs have differences but they do the same job: they run Python codes and debugs them for us. They have same error messages to help us in coding.

The use of a Notebook or an IDE depends on what you are comfortable with and what is your purpose. For me, I prefer coding first in Spyder especially if I will be building long programs and will be dealing with numerous data sets. Maybe, I will then upload it in the notebook once its done and final. If the codes will be used by another user or will implemented again after some time, notebook will be helpful because if they will edit things out, all will be included in the revisions log. Of course, like any other things in this world, my preference might change.

It will always depend on what you are comfortable with and what your purpose is. After all, there are no hard and fast rules in this world.

A statistician, aspiring to be a unicorn