Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

suppress python vs try/except pass

# 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 #pass
ADD COMMENT
Topic
Name
7+3 =