What is the use of Pass statement in Python?

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


Posted

in

Tags:

Comments

Leave a Reply