Often I need to temporary comment some code, but there are situations like the following where commenting a single line of code will get a syntax error
if state == False:
print "Here I'm not good do stuff"
else:
# print "I am good here but stuff might be needed to implement"
Is there something that might act as an NOOP to keep this syntax correct?
The operation you're looking for is pass
. So in your example it would look like this:
if state == False:
print "Here I'm not good do stuff"
else:
pass
# print "I am good here but stuff might be needed to implement"
You can read more about it here: http://docs.python.org/py3k/reference/simple_stmts.html#pass
In Python 3, ...
makes a pretty good pass
substitute:
class X:
...
def x():
...
if x:
...
I read it as "to be done", whereas pass
means "this page intentionally left blank".
It's actually just a literal, much like None
, True
and False
, but they optimize out all the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With