Developpez.com

Python

Choisissez la catégorie, puis la rubrique :

29.4 modulefinder -- Find modules used by a script

29.4 modulefinder -- Find modules used by a script

New in version 2.3.

This module provides a ModuleFinder class that can be used to determine the set of modules imported by a script. modulefinder.py can also be run as a script, giving the filename of a Python script as its argument, after which a report of the imported modules will be printed.

AddPackagePath( pkg_name, path)
Record that the package named pkg_name can be found in the specified path.

ReplacePackage( oldname, newname)
Allows specifying that the module named oldname is in fact the package named newname. The most common usage would be to handle how the _xmlplus package replaces the xml package.

class ModuleFinder( [path=None, debug=0, excludes=[], replace_paths=[]])

This class provides run_script() and report() methods to determine the set of modules imported by a script. path can be a list of directories to search for modules; if not specified, sys.path is used. debug sets the debugging level; higher values make the class print debugging messages about what it's doing. excludes is a list of module names to exclude from the analysis. replace_paths is a list of (oldpath, newpath) tuples that will be replaced in module paths.

report( )
Print a report to standard output that lists the modules imported by the script and their paths, as well as modules that are missing or seem to be missing.

run_script( pathname)
Analyze the contents of the pathname file, which must contain Python code.

See About this document... for information on suggesting changes.
Netflix : Python est derrière chaque film que vous regardez, voici comment l'entreprise utilise le langage de programmation pour ses services
Une plateforme de recrutement s'intéresse aux tendances des ingénieurs en matière d'outils de développement, et note la montée en puissance de VS Code
Les tendances des développeurs pour 2019 font du Machine Learning la compétence clé et du JavaScript le langage le plus populaire
Apprendre à coder correctement - Un guide concis pour écrire un meilleur code, par Robat Williams, traduit par vavavoum74
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web