Skip to content

print (T201)#

Derived from the flake8-print linter.

What it does#

Checks for print statements.

Why is this bad?#

print statements are useful in some situations (e.g., debugging), but should typically be omitted from production code. print statements can lead to the accidental inclusion of sensitive information in logs, and are not configurable by clients, unlike logging statements.


def add_numbers(a, b):
    print(f"The sum of {a} and {b} is {a + b}")
    return a + b

Use instead:

def add_numbers(a, b):
    return a + b