Skip to content

Commit 50f2397

Browse files
committed
Mention dir support in importlib.resources docs
1 parent a6675b1 commit 50f2397

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Doc/library/importlib.resources.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@ for example, a package and its resources can be imported from a zip file using
8282
.. function:: as_file(traversable)
8383

8484
Given a :class:`~importlib.resources.abc.Traversable` object representing
85-
a file, typically from :func:`importlib.resources.files`, return
86-
a context manager for use in a :keyword:`with` statement.
85+
a file or directory, typically from :func:`importlib.resources.files`,
86+
return a context manager for use in a :keyword:`with` statement.
8787
The context manager provides a :class:`pathlib.Path` object.
8888

89-
Exiting the context manager cleans up any temporary file created when the
90-
resource was extracted from e.g. a zip file.
89+
Exiting the context manager cleans up any temporary file or directory
90+
created when the resource was extracted from e.g. a zip file.
9191

9292
Use ``as_file`` when the Traversable methods
93-
(``read_text``, etc) are insufficient and an actual file on
93+
(``read_text``, etc) are insufficient and an actual file or directory on
9494
the file system is required.
9595

9696
.. versionadded:: 3.9
97+
98+
.. versionchanged:: 3.12
99+
Support added for `traversable` representing to a directory.

0 commit comments

Comments
 (0)