File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -888,6 +888,22 @@ The following functions are available.
888
888
889
889
.. versionadded :: 3.9
890
890
891
+ .. function :: as_file(traversable)
892
+
893
+ Given a :class: `importlib.resources.abc.Traversable ` object representing
894
+ a file, typically from :func: `importlib.resources.files `, return
895
+ a context manager for use in a :keyword: `with ` statement.
896
+ The context manager provides a :class: `pathlib.Path ` object.
897
+
898
+ Exiting the context manager cleans up any temporary file created when the
899
+ resource was extracted from e.g. a zip file.
900
+
901
+ Use ``as_file `` when the Traversable methods
902
+ (``read_text ``, etc) are insufficient and an actual file on
903
+ the file system is required.
904
+
905
+ .. versionadded :: 3.9
906
+
891
907
.. function :: open_binary(package, resource)
892
908
893
909
Open for binary reading the *resource * within *package *.
You can’t perform that action at this time.
0 commit comments