Python - Get names of built-in modules of sys module

By IncludeHelp Last updated : February 8, 2024

Problem statement

Write a Python program to get the names of built-in modules of the sys module.

Getting names of built-in modules of sys module

In Python, you can use the builtin_module_names attribute of the sys module to get the names of all built-in modules of the sys module. The sys.builtin_module_names returns a tuple containing names of all built-in modules.

Syntax

sys.builtin_module_names

Python program to get names of built-in modules of sys module

# Importing sys Module
import sys

# Getting built-in module names
builtin_modules = sys.builtin_module_names

# Printing
print(builtin_modules)

Output

The output of the above program is:

('_abc', '_ast', '_bisect', '_blake2', '_codecs', '_collections', 
'_csv', '_datetime', '_elementtree', '_functools', '_heapq', '_imp', 
'_io', '_locale', '_md5', '_operator', '_pickle', 
'_posixsubprocess', '_random', '_sha1', '_sha256', '_sha3', 
'_sha512', '_signal', '_socket', '_sre', '_stat', '_statistics', 
'_string', '_struct', '_symtable', '_thread', '_tracemalloc', 
'_warnings', '_weakref', 'array', 'atexit', 'binascii', 'builtins', 
'cmath', 'errno', 'faulthandler', 'fcntl', 'gc', 'grp', 'itertools', 
'marshal', 'math', 'posix', 'pwd', 'pyexpat', 'select', 'spwd', 
'sys', 'syslog', 'time', 'unicodedata', 'xxsubtype', 'zlib')

To understand the above program, you should have the basic knowledge of the following Python topics:

 
 

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.