PyDocs

Nav

Importing Modules

Distribution.read_text

  • Distribution.read_text(filename)
Attempt to load metadata file given by the name.

Python distribution metadata is organized by blobs of text
typically represented as "files" in the metadata directory
(e.g. package-1.0.dist-info). These files include things
like:

- METADATA: The distribution metadata including fields
  like Name and Version and Description.
- entry_points.txt: A series of entry points as defined in
  `the entry points spec <https://packaging.python.org/en/latest/specifications/entry-points/#file-format>`_.
- RECORD: A record of files according to
  `this recording spec <https://packaging.python.org/en/latest/specifications/recording-installed-packages/#the-record-file>`_.

A package may provide any set of files, including those
not listed here or none at all.

:param filename: The name of the file in the distribution info.
:return: The text if found, otherwise None.
1 Example
>>> print(util.read_text())
import base64
import sys
...
def as_bytes(s):
    if isinstance(s, text_type):
        return s.encode('utf-8')
    return s
from the Python docs
See Also
No see-alsos for importlib.metadata/Distribution.read_text
0 Notes
No notes for Distribution.read_text