Python Start • March 4, 2017
The list of Python Packages is Massive
Python's geometric rise is due, at least in part, to a tremendous list of packages
Python has experienced tremendous recent adoption for at least 5 reasons. One of those reasons is the vast set of available Python packages.
What is a Python Module?
In order to understand Python packages, it's helpful to first understand Python modules. Modules are individual Python files that can be imported and interpreted at run-time. For example, you could create a file named log_search.py
in the current directory and then import the module using the import
command. You can then access the log_search functions from your main application module. We'll dive into modules and functions in more detail, but for now think of a module as a collection of definitions and statements that comprise a set of related capabilities. Each function within a module is accessed using the module name, followed by a period (.) like this:
import log_search
log_search.find("pythonstart.com")
What is a Python Package?
A package is a collection of Python modules. This lets you organize even larger sets of capabilities into a single package. For example, perhaps you want to create an log_analysis
package that includes many different sets of capabilities, and perhaps it will grow over time. Within this package, you want to include a set of functions that let users search log files (log_search) and a set of functions to append, split, and save log files, which you'll call (log_file_ops). Each module is a file that sits within a log_analysis
folder. You can even nest packages, so that you can include multiple packages in a single web_ops package. To do this, you simply create a top-level folder named web_ops, add the log_analysis
folder and create sibling folders such as web_server. Below is a view of the folder structure:
web_ops/ Top-level package
__init__.py Initialize the web_ops packageweb_server/ Subpackage for web server functionality
log_analysis/ Subpackage for log analysis functionality__init__.py Initialize the web_server packagedeploy.py Functions to deploy your web serverstart.py Functions to start your web server
__init__.py Initialize the log_analysis packagelog_search.py Functions to search your logslog_file_ops.py Functions to modify your log files
Popular Python Packages
Below are a few popular Python packages as examples: