@@ -159,25 +159,14 @@ included in one of the following places:
159
159
The preferred way to access the data from Python is using the
160
160
`importlib.resources API <https://importlib-resources.readthedocs.io/en/latest/using.html> `,
161
161
in particular the function :func: `importlib.resources.files `.
162
- It should be imported as follows
163
- (see :ref: `section-python-language-standard `)::
164
-
165
- import sys
166
-
167
- if sys.version_info < (3, 11):
168
- # Use backport package providing Python 3.11 features
169
- from importlib_resources import files
170
- else:
171
- from importlib.resources import files
172
-
173
- After this import, you can:
174
-
175
- - open a resource for text reading: `fd = files(package).joinpath(resource).open('rt') `
176
- - open a resource for binary reading: `fd = files(package).joinpath(resource).open('rb') `
177
- - read a resource as text: `text = files(package).joinpath(resource).read_text() `
178
- - read a resource as bytes: `bytes = files(package).joinpath(resource).read_bytes() `
179
- - open a xz resource for text reading: `fd = lzma.open(files(package).joinpath(resource).open('rb'), 'rt') `
180
- - open a xz resource for binary reading: `fd = lzma.open(files(package).joinpath(resource).open('rb'), 'rb') `
162
+ Using it, you can:
163
+
164
+ - open a resource for text reading: ``fd = files(package).joinpath(resource).open('rt') ``
165
+ - open a resource for binary reading: ``fd = files(package).joinpath(resource).open('rb') ``
166
+ - read a resource as text: ``text = files(package).joinpath(resource).read_text() ``
167
+ - read a resource as bytes: ``bytes = files(package).joinpath(resource).read_bytes() ``
168
+ - open an xz-compressed resource for text reading: ``fd = lzma.open(files(package).joinpath(resource).open('rb'), 'rt') ``
169
+ - open an xz-compressed resource for binary reading: ``fd = lzma.open(files(package).joinpath(resource).open('rb'), 'rb') ``
181
170
182
171
If the file needs to be used outside of Python, then the
183
172
preferred way is using the context manager
0 commit comments