# Feature or enhancement ### Proposal: The `importlib.resources` functions `{open,read}_{text,binary}`, `path`, `is_resource` and `contents`, deprecated in 3.11 and removed in 3.13 alphas, are, anecdotally, missed by quite a few users. They provide a simple API for simple tasks, while the full-featured `Traversable` API is better suited for complex ones -- especially for implementing new resources-aware loaders. I'm now in a position where I can add these functions back and support them. Their main drawback -- not allowing subdirectories -- can be solved by taking multiple path components as positional arguments, for example: ```python importlib.resources.read_text('modulename', 'subdirectory', 'subsubdir', 'resource.txt') ``` The additional arguments (*encoding* and *errors*) would become keyword-only. --- There is a wrinkle in this: in Python 3.9-3.11, the above would mean: ```python importlib.resources.read_text( 'modulename', 'subdirectory', encoding='subsubdir', errors='resource.txt', ) ``` ~~I believe that this is acceptable, since:~~ - ~~pragmatically: typical file names do not match typical encoding/errorhandler names~~ - ~~lawyerly: the functions have already been deprecated for 2 releases; no one is using them now, right?~~ ~~However, if this is a problem, I can~~ [edit: This is solved by:] - make the `encoding` argument *required* if a text-reading function more than one path component is given. - plan to lift this limitation around 3.15. ```python importlib.resources.read_text( 'modulename', 'subdirectory', 'subsubdir', 'resource.txt', encoding='utf-8', ) importlib.resources.read_text('modulename', 'resource.txt') # OK importlib.resources.read_text('modulename', 'subdirectory', 'utf-8') # error ``` ### Has this already been discussed elsewhere? I have already discussed this feature proposal on Discourse ### Links to previous discussion of this feature: https://discuss.python.org/t/deprecating-importlib-resources-legacy-api/11386/29 <!-- gh-linked-prs --> ### Linked PRs * gh-116609 * gh-117569 * gh-123028 * gh-123051 * gh-123072 * gh-123074 * gh-132206 <!-- /gh-linked-prs -->