Skip to content

Commit b38b2fa

Browse files
authored
Document importlib.metadata.PackagePath.locate method (GH-25669)
1 parent 4a85718 commit b38b2fa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Doc/library/importlib.metadata.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Distribution files
191191
You can also get the full set of files contained within a distribution. The
192192
``files()`` function takes a distribution package name and returns all of the
193193
files installed by this distribution. Each file object returned is a
194-
``PackagePath``, a :class:`pathlib.Path` derived object with additional ``dist``,
194+
``PackagePath``, a :class:`pathlib.PurePath` derived object with additional ``dist``,
195195
``size``, and ``hash`` properties as indicated by the metadata. For example::
196196

197197
>>> util = [p for p in files('wheel') if 'util.py' in str(p)][0] # doctest: +SKIP
@@ -215,6 +215,12 @@ Once you have the file, you can also read its contents::
215215
return s.encode('utf-8')
216216
return s
217217

218+
You can also use the ``locate`` method to get a the absolute path to the
219+
file::
220+
221+
>>> util.locate() # doctest: +SKIP
222+
PosixPath('/home/gustav/example/lib/site-packages/wheel/util.py')
223+
218224
In the case where the metadata file listing files
219225
(RECORD or SOURCES.txt) is missing, ``files()`` will
220226
return ``None``. The caller may wish to wrap calls to

0 commit comments

Comments
 (0)