English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python basic tutorial

Python flow control

Python Functions

Python Data Types

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python reference manual

Python pass Statement

In this article, you will learn about the pass statement. It is used as a placeholder for implementing functions, loops, and so on later.

What is the pass statement in Python?

In Python programming, the pass statement is an empty statement. In Python,CommentsThe difference between and pass statement is that, although the interpreter completely ignores comments, pass is not ignored.

However, there is no response when passing execution. The result is no operation (NOP).

pass syntax

pass

We usually use it as a placeholder.

Suppose we have an unimplementedLooporfunctionBut we want to implement it in the future. They cannot have an empty body, the interpreter will give an error. Therefore, we use the pass statement to construct a body that does not perform any operation.

Example: pass statement

'''pass is just a placeholder,
for adding features in the future. '''
sequence = {'p', 'a', 's', 's'}
for val in sequence:
    pass

We can also use it in an emptyfunctionorIn the classPerform the same operation.

def function(args):
    pass
class Example:
    pass