Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9af9ac1

Browse files
scopAA-Turner
andauthored
gh-66944: Note that thecontextlib.closing example is for illustrative purposes (#112198)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
1 parent647b6cc commit9af9ac1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎Doc/library/contextlib.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ Functions and classes provided:
182182
without needing to explicitly close ``page``. Even if an error occurs,
183183
``page.close()`` will be called when the:keyword:`with` block is exited.
184184

185+
..note::
186+
187+
Most types managing resources support the:term:`context manager` protocol,
188+
which closes *thing* on leaving the:keyword:`with` statment.
189+
As such,:func:`!closing` is most useful for third party types that don't
190+
support context managers.
191+
This example is purely for illustration purposes,
192+
as:func:`~urllib.request.urlopen` would normally be used in a context manager.
185193

186194
..function::aclosing(thing)
187195

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp