The Art of doing nothing: Python Edition
Tags: python, beginners
Published: 2020-12-26 20:57:34

Writing programs can be stressful. As a developer, I have never been one to always pen down pseudo-codes before writing my first lines of code so it happens that at some point I do not know what to write. Also, when writing modular scripts, I define all classes/functions and their doc-strings at the start before completing them one after the other. 

This means I had to find ways to make empty classes or functions not raise errors when the script is run. I have discovered a couple of ways to do this and I  will be sharing them in this article. Whether you are like me or not, I do not doubt that you will find this interesting and useful.

## **The package called nothing**
The mere fact that a python developer created this is quite fascinating. Here we have a package that contains [nothing](https://pypi.org/project/nothing/) but a version number and a one-sentence description in its [init](https://stackoverflow.com/questions/448271/what-is-init-py-for#:~:text=The%20__init__.py%20file%20makes%20Python%20treat%20directories,the%20submodules%20to%20be%20exported.) file. In fact, this is the only description for this package on [Github](https://github.com/Carreau/nothing) and [PyPI](https://pypi.org/nothing), nothing else. Like every other package, it can be installed with pip via the command `pip install nothing`.

Once it is installed, we can `import nothing` and then use it as a placeholder as shown below

<table>
  <tr>
    <td><img src="https://dev-to-uploads.s3.amazonaws.com/i/up5i4601sv578yvx8suw.png" width=270 height=480></td>
    <td><img src="https://dev-to-uploads.s3.amazonaws.com/i/1gdfmosapve43isvozxm.png" width=270 height=480></td>
  </tr>
 </table>

## **The pass statement**
This is the more popular option. `pass` is an inbuilt null statement in python that is used to stand in for code that is yet to be written. Its inbuilt nature makes it most python developers goto statement for code blocks that are to do nothing. It is used like the nothing package as we'll see in the image below.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/s2yedkrwoczpw8esdbya.png)

## **Ellipsis (...)**
In the English language, an ellipsis is used when omitting a word, phrase, line, paragraph, or more from a quoted passage. In Python, however, an ellipsis is a single object with no methods that serve a range of functions from multi-dimensional array slicing to type hinting but we will be focusing on its use as a placeholder. This is a personal favourite because I find the similarity between its use case in python and regular English texts interesting. We see it used in the image below as a part of a recursive function with only the base case specified.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/lp8hvq11nb6fgueb68w3.png)

## **The final straw**
This last case is quite intriguing. Its something you would have thought of at some point and simply put, it is *leaving your editor empty*. Why type when you are not ready yet? Finish up that pseudo-code then open your editor and code away. Yes, this is a message to me too😂

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/fcxlf10o6wzm660g59t3.png)

I hope I successfully communicated the art of doing nothing in Python to you all and that this was enjoyable.