Pass Statement

Placeholder for empty blocks

Interview Relevant: Python-specific

Pass Statement

Placeholder that does nothing.

Code Examples

Using pass as a placeholder.

python
1# Empty function body
2def not_implemented():
3    pass
4
5# Empty class
6class EmptyClass:
7    pass
8
9# Empty loop (waiting)
10while not ready():
11    pass
12
13# Empty except block (not recommended)
14try:
15    risky_operation()
16except:
17    pass  # Silently ignore
18
19# Placeholder in if
20if condition:
21    pass  # TODO: implement
22else:
23    do_something()

AI Tutor

Ask about the topic

Sign in Required

Please sign in to use the AI tutor

Sign In