MemotivaContext managers and the with statement

What is contextlib.suppress?

Context managers and the with statement

Audio flashcard · 0:14

Nortren·

What is contextlib.suppress?

0:14

Suppress is a context manager that swallows specified exceptions. It is a clean alternative to a try-except block where you want to ignore certain errors. For example, suppress FileNotFoundError around an os.remove call avoids cluttering the code with empty handlers.
docs.python.org