Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

suppress python vs try/except

# The suppress suppresses the error and continues from after the 'with' statement.
from contextlib import suppress
with suppress(Exception):
    print("This will print")
    raise Exception
    print("This won't print")

print("This will also print")
 
PREVIOUS NEXT
Tagged: #suppress #python
ADD COMMENT
Topic
Name
5+4 =