In python, is there a way to keep the indentation of a block of code within the control statement when commenting out the control statement?
The use case would be a situation where you want to temporarily comment out an if-statement
, but don't want to unindent the nested code. Am looking for a dummy control statement as follows:
Originally:
if condition is True:
print('print')
Temporarily:
#if condition is True:
dummy_control_statement:
print('print')
Here a couple of options that might work for you:
if False and original-condition
: (easily replace all False and
with empty string to revert)if False:
(if you prefer to comment out the original line of code)