Remove Debug

This transform removes if statements that test __debug__ is True.

The builtin __debug__ constant is True if Python is not started with the -O option. This transform is only safe to use if the minified output will by run with the -O option, or you are certain that any if statement that tests __debug__ can be removed.

The condition is not evaluated. The statement is only removed if the condition exactly matches one of the forms in the example below.

If a statement is required, the if statement will be replaced by a zero expression statement.

The transform is disabled by default. Enable it by passing the remove_debug=True argument to the python_minifier.minify() function, or passing --remove-debug to the pyminify command.

Example

Input

value = 10

# Truthy
if __debug__:
    value += 1

if __debug__ is True:
    value += 1

if __debug__ is not False:
    value += 1

if __debug__ == True:
    value += 1


# Falsy
if not __debug__:
    value += 1

if __debug__ is False:
    value += 1

if __debug__ is not True:
    value += 1

if __debug__ == False:
    value += 1

print(value)

Output

value=10
if not __debug__:value+=1
if __debug__ is False:value+=1
if __debug__ is not True:value+=1
if __debug__==False:value+=1
print(value)