File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -166,10 +166,12 @@ included in one of the following places:
166166 It should be imported as follows
167167 (see :ref: `section-python-language-standard `)::
168168
169- try:
169+ import sys
170+
171+ if sys.version_info < (3, 11):
170172 # Use backport package providing Python 3.11 features
171173 from importlib_resources import files
172- except ImportError :
174+ else :
173175 from importlib.resources import files
174176
175177 After this import, you can:
@@ -183,14 +185,8 @@ included in one of the following places:
183185
184186 If the file needs to be used outside of Python, then the
185187 preferred way is using the context manager
186- :func: `importlib.resources.as_file `. It should be imported as
187- follows::
188-
189- try:
190- # Use backport package providing Python 3.11 features
191- from importlib_resources import as_file
192- except ImportError:
193- from importlib.resources import as_file
188+ :func: `importlib.resources.as_file `. It should be imported in the
189+ same way as shown above.
194190
195191 .. NOTE ::
196192
You can’t perform that action at this time.
0 commit comments