Skip to main content

Modules and libraries

Hello again!
Previously, we learned about built-in functions in Python.
Built-in functions come standard with every version of Python and consist of functions such as print(), type(), max(), and many more.
To access additional pre-built functions, you can import a library.
A library is a collection of modules that provide code users can access in their programs.
All libraries are generally made up of several modules.
A module is a Python file that contains additional functions, variables, classes, and any kind of runnable code.
Think of them as saved Python files that contain useful functionality.
Modules may be made up of small and simple lines of code or be complex and lengthy in size.
Either way, they help save programmers time and make code more readable.
Now, let's focus specifically on the Python Standard Library.
The Python Standard Library is an extensive collection of usable Python code that often comes packaged with Python.
One example of a module from the Python Standard Library is the re module.
This is a useful module for a security analyst when they're tasked with searching for patterns in log files.
Another module is the csv module.
It allows you to work efficiently with CSV files.
The Python Standard Library also contains glob and os modules for interacting with the command line as well as time and datetime for working with timestamps.
These are just a few of the modules in the Python Standard Library.
In addition to what's always available through the Python Standard Library, you can also download external libraries.
A couple of examples are Beautiful Soup for parsing HTML website files and NumPy for arrays and mathematical computations.
These libraries will assist you as a security analyst in network traffic analysis, log file parsing, and complex math.
Overall, Python libraries and modules are useful because they provide pre-programmed functions and variables.
This saves time for the user.
I encourage you to explore some of the libraries and modules we discussed here and the ways they might be helpful to you as you work in Python.