The use of Pass statement is to do nothing. It is just a placeholder for a statement that is required for syntax purpose. It does not execute any code or command.
Some of the use cases for pass statement are as follows:
I. Syntax purpose:
>>> while True: โฆ pass # Wait till user input is received
II. Minimal Class: It can be used for creating minimal classes:
>>> class MyMinimalClass: โฆ pass
III. Place-holder for TODO work: We can also use it as a placeholder for TODO work on a function or code that needs to be implemented at a later point of time.
>>> def initialization(): โฆ pass # TODO
Leave a Reply