try:
lst = [1, 2, 3, 4, 5]
print(lst[10])
except IndexError:
passThat will work (without printing anything), but
contextlib let you do the same more expressively and semantically correct:from contextlib import suppress
with suppress(IndexError):
lst = [1, 2, 3, 4, 5]
lst[10]