Python Pass
In Python, the pass keyword is used to execute nothing; it means, when we don't want to execute code, the pass can be used to execute empty. It is the same as the name refers to. It just makes the control to pass by without executing any code. If we want to bypass any code pass statement can be used.
It is beneficial when a statement is required syntactically, but we want we don't want to execute or execute it later. The difference between the comments and pass is that, comments are entirely ignored by the Python interpreter, where the pass statement is not ignored.
Suppose we have a loop, and we do not want to execute right this moment, but we will execute in the future. Here we can use the pass.
Consider the following example.
Example - Pass statement
Example - 2:
Output:
We can create empty class or function using the pass statement.
0 comments:
Post a Comment
Thanks