Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The pass Statement

The pass statement does nothing. Sometimes we need a placeholder to fill the syntactic requirements of a compound statement. We use the pass statement to fill in the required suite of statements.

The syntax is trivial.

pass

Here's an example of using the pass statement.

if n%2 == 0:
    pass # Ignore even values
else:
    count += 1 # Count the odd values

Yes, technically, we can invert the logic in the if-clause. However, sometimes it is more clear to provide the explicit "do nothing" than to determine the inverse of the condition in the if statement.

As programs grow and evolve, having a pass statement can be a handy reminder of places where a program can be expanded.


 
 
  Published under the terms of the Open Publication License Design by Interspire