콘텐츠로 이동
Search

Python:contextlib

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())

See also

Favorite site

lastmod 2024-02-06created 2024-02-06author Zer0 sitemap