"
This article is part of in the series
Published: Thursday 9th February 2017

In Python, the pass statement, much like a comment, is considered a null statement, meaning that it doesn't result in any Python operations. The only difference between a comment and a pass statement is that while a comment is completely ignored by the interpreter, the pass statement is not (but, like a comment statement, nothing is executed because of a pass).

A good way to use pass is to hold the place of code that isn't ready or hasn't been written yet. Often it takes the place of loops or functions. To use it, you just need to type the word "pass" where you would normally insert any other code (like a loop or a function). To see it in context, check out the example below:

count = 0
while (count < 4):
   pass

As you can see, we've got a while look that is going to execute some code while the count is less than 4. Let's say this is your code, but you haven't finished writing the while loop, and want to move on to something else and go back to it later. This is the perfect time to use the pass statement. Your code won't actually do anything, but at least you've got it set up, properly formatted, and ready to go for when your code is completed.

Of course, you could also use a comment here to remind your future self of your plans for your function, but if you're looking for a simpler solution, implementing a pass statement is quicker and easier than writing out an entire comment -- it only takes four characters and about .4 seconds to type out. Just make sure you don't forget to go back in later and add your desired function, loop, or other snippet, otherwise you might run into some real problems with the execution of your code.