Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Python Standard Library List

This package includes lists of all of the standard libraries for Python 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, and 3.9 along with the code for scraping the official Python docs to get said lists.

Note: from Python 3.10 onwards one can use the following one-liner to get the list of available modules:

>>> builtin_modules = list(set(list(sys.stdlib_module_names) + list(sys.builtin_module_names)))

Thus, this package will not get any more updates.


Listing the modules in the standard library? Wait, why on Earth would you care about that?!
-------------------------------------------------------------------------------------------

Expand All @@ -21,4 +28,3 @@ Usage
['AL', 'BaseHTTPServer', 'Bastion', 'CGIHTTPServer', 'ColorPicker', 'ConfigParser', 'Cookie', 'DEVICE', 'DocXMLRPCServer', 'EasyDialogs']

For more details, check out [the docs](http://python-stdlib-list.readthedocs.org/en/latest/).

19 changes: 15 additions & 4 deletions stdlib_list/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
import os
import pkgutil
import sys
import warnings

try:
from functools import lru_cache
except ImportError:
from functools32 import lru_cache

long_versions = ["2.6.9", "2.7.9", "3.2.6", "3.3.6", "3.4.3", "3.5", "3.6",
"3.7", "3.8", "3.9"]
"3.7", "3.8", "3.9", "3.10", "3.11"]

short_versions = [".".join(x.split(".")[:2]) for x in long_versions]

builtin_versions = ["3.10", "3.11"]
warning_message = (
"This package is no longer needed to get Python stdlib modules on Python 3.10+."
"Python itself provides such list, see the one line on the README."
)

def get_canonical_version(version):

Expand Down Expand Up @@ -42,11 +48,16 @@ def stdlib_list(version=None):
version = get_canonical_version(version) if version is not None else '.'.join(
str(x) for x in sys.version_info[:2])

module_list_file = os.path.join("lists", "{}.txt".format(version))
if version in builtin_versions:
result = list(set(list(sys.stdlib_module_names) + list(sys.builtin_module_names)))

data = pkgutil.get_data("stdlib_list", module_list_file).decode()
warnings.warn(warning_message, DeprecationWarning)
else:
module_list_file = os.path.join("lists", "{}.txt".format(version))

result = [y for y in [x.strip() for x in data.splitlines()] if y]
data = pkgutil.get_data("stdlib_list", module_list_file).decode()

result = [y for y in [x.strip() for x in data.splitlines()] if y]

return result

Expand Down