I am in the process of learning Python and I have reached the section about the pass statement. The guide I’m using defines it as being a null statement that is commonly used as a placeholder.
I still don’t fully understand what that means though. What would be a simple/basic situation where the pass statement would be used and why would it be needed?
Suppose you are designing a new class with some methods that you don’t want to implement, yet.
If you were to leave out the
pass, the code wouldn’t run.You would then get an:
To summarize, the
passstatement does nothing particular, but it can act as a placeholder, as demonstrated here.