Skip to content

gh-88330: Add more detail about what is a resource. #99801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Doc/library/importlib.resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@
.. versionadded:: 3.7

This module leverages Python's import system to provide access to *resources*
within *packages*. If you can import a package, you can access resources
within that package. Resources can be opened or read, in either binary or
text mode.
within *packages*.

"Resources" are file-like resources associated with a module or package in
Python. The resources may be contained directly in a package or within a
subdirectory contained in that package. Resources may be text or binary. As a
result, Python module sources (.py) of a package and compilation artifacts
(pycache) are technically de-facto resources of that package. In practice,
however, resources are primarily those non-Python artifacts exposed
specifically by the package author.

Resources can be opened or read in either binary or text mode.

Resources are roughly akin to files inside directories, though it's important
to keep in mind that this is just a metaphor. Resources and packages **do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved the description of what a resource is in importlib.resources docs.