metadata
moduleThe metadata
module in importlib
module provides the metadata information about the installed modules. This module, along with importlib.resources
module, replaces the older pkg_resources
module.
Some of the metadata attributes are package version, name, description, and so on.
Note: Refer to Core metadata specifications to get all metadata attributes.
metadata()
methodThe metadata()
method of the metadata
module provides all the core metadata specifications about a package.
metadata.metadata(pkg_name)
The pkg_name
is the package name.
The method returns an object that contains all metadata information about the package.
Let’s look at the code example:
from importlib import metadatasp_data = metadata.metadata("setuptools")print("Metadata about setuptools pacakge:")print("Version - ", sp_data['Version'])print("Summary - ", sp_data['Summary'])print("-"*8)print("Metadata dictionary - ")print(dict(sp_data))
metadata
module.setuptools
package using the metadata()
method.