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