Python:contextlib
lastmod 2024-02-06created 2020-12-262 edits
Closing
from contextlib import closing
from urllib.request import urlopen
with closing(urlopen('http://www.python.org')) as page:
for line in page:
print(line)
suppress
import asyncio as _asyncio
from contextlib import suppress
with suppress(ImportError):
import uvloop as _uvloop
_asyncio.set_event_loop_policy(_uvloop.EventLoopPolicy())