Python NOOP replacement

Eduard Florinescu picture Eduard Florinescu · Sep 18, 2012 · Viewed 8.1k times · Source

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?

Answer

while picture while · Sep 18, 2012

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