Over the course of development it sometimes becomes necessary to temporarily comment out blocks of code for testing purposes.
Sometimes these comments require re-indentation of code fragments that could become difficult to take back later without introducing errors.
I was wondering whether there was a "blank indentation" operator, sort of the opposite of "pass"
Example:
def func(x):
if x == 0:
print("Test")
For testing, I am commenting out the "if" temporarily, which breaks indentation:
def func(x):
# if x == 0:
print("Test")
I want to avoid re-indentation like this, since it's only a temporary change and it could mess up more complex code:
def func(x):
# if x == 0:
print("Test")
Question: Is there something like this?
def func(x):
# if x == 0:
force_indent:
print("Test")
Of course, I could do the following, I was just wondering whether there was some sort of idiom or better way to do this:
def func(x):
# if x == 0:
if True:
print("Test")
if True:seems to be the closest you'll get to this behaviour but some other statement might work betterx == 0to__debug__ or x == 0if True: # x==0:seems like the easiest approach.if 1:if you want to type fewer characters. But as @khelwood saysif 1: # x==0:would be neater.