aboutsummaryrefslogtreecommitdiff
path: root/Doc
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2021-01-25 13:24:42 +0100
committerGitHub <noreply@github.com>2021-01-25 13:24:42 +0100
commitdb584bdad32d81e42b71871077a8008036f5c048 (patch)
treeef018339067b08456b55a083547f9427b817f1b3 /Doc
parentbpo-43013: Fix old tkinter module names in idlelib (GH-24326) (diff)
downloadcpython-db584bdad32d81e42b71871077a8008036f5c048.tar.gz
cpython-db584bdad32d81e42b71871077a8008036f5c048.tar.bz2
cpython-db584bdad32d81e42b71871077a8008036f5c048.zip
bpo-42955: Add sys.modules_names (GH-24238)
Add sys.module_names, containing the list of the standard library module names.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/sys.rst22
-rw-r--r--Doc/whatsnew/3.10.rst4
2 files changed, 25 insertions, 1 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 0f13adcf0e5..d536fc9322e 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -153,10 +153,12 @@ always available.
.. data:: builtin_module_names
- A tuple of strings giving the names of all modules that are compiled into this
+ A tuple of strings containing the names of all modules that are compiled into this
Python interpreter. (This information is not available in any other way ---
``modules.keys()`` only lists the imported modules.)
+ See also the :attr:`sys.module_names` list.
+
.. function:: call_tracing(func, args)
@@ -1060,6 +1062,24 @@ always available.
This is still called as a fallback if a :data:`meta_path` entry doesn't
have a :meth:`~importlib.abc.MetaPathFinder.find_spec` method.
+.. data:: module_names
+
+ A frozenset of strings containing the names of standard library modules.
+
+ It is the same on all platforms. Modules which are not available on
+ some platforms and modules disabled at Python build are also listed.
+ All module kinds are listed: pure Python, built-in, frozen and extension
+ modules. Test modules are excluded.
+
+ For packages, only sub-packages are listed, not sub-modules. For example,
+ ``concurrent`` package and ``concurrent.futures`` sub-package are listed,
+ but not ``concurrent.futures.base`` sub-module.
+
+ See also the :attr:`sys.builtin_module_names` list.
+
+ .. versionchanged:: 3.10
+
+
.. data:: modules
This is a dictionary that maps module names to modules which have already been
diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index d822dda09d2..a6c3fbbff91 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -396,6 +396,10 @@ Add :data:`sys.orig_argv` attribute: the list of the original command line
arguments passed to the Python executable.
(Contributed by Victor Stinner in :issue:`23427`.)
+Add :data:`sys.module_names`, containing the list of the standard library
+module names.
+(Contributed by Victor Stinner in :issue:`42955`.)
+
threading
---------