We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
contextlib.closing
1 parent 647b6cc commit 9af9ac1Copy full SHA for 9af9ac1
Doc/library/contextlib.rst
@@ -182,6 +182,14 @@ Functions and classes provided:
182
without needing to explicitly close ``page``. Even if an error occurs,
183
``page.close()`` will be called when the :keyword:`with` block is exited.
184
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.
193
194
.. function:: aclosing(thing)
195
0 commit comments