Tip: Use string literals instead of the pass statement?
The pass statement is simply used where the Python syntax requires a statement, but the application doesn’t need any logic. Typically it is accompanied by a comment explaining why it is there. A simple example:
my custom exception
class MyException(Exception): pass if condition: pass # we don’t need this right now - testing
More often than not I will use a triple quoted string in its place. This makes it more self documenting and looks cleaner to me. My preferred usage:
class MyException(Exception):
"""my custom exception"""
if condition:
"we don't need this right now - testing"
What do you prefer?
July 26, 2008 | Filed Under python
Comments
-
Juri Pakaste
-
Mike
-
Roberto
-
Remco Gerlich
-
Marius Gedminas
-
k3rni
-
Doug Napoleone
-
Luka Marinko
-
Benjamin Peterson
-
Aaron








