PyDocs

Nav

Python Runtime Services

suppress

contextlib

function · Added in 3.4 (source)
  • suppress(*exceptions)
Context manager to suppress specified exceptions

After the exception is suppressed, execution proceeds with the next
statement following the with statement.

     with suppress(FileNotFoundError):
         os.remove(somefile)
     # Execution still resumes here if the file was already removed
Changed in 3.12
  • 3.12: suppress now supports suppressing exceptions raised as part of a BaseExceptionGroup.
0 Examples
No examples for contextlib/suppress.
See Also
No see-alsos for contextlib/suppress
0 Notes
No notes for suppress