How to Create a Python Package
Discover how to build custom Python packages by organizing related modules within proper folder structures including multiple __init__.py files. Learn to simplify package use with initialization code and install packages using setup scripts or by modifying Python’s path. This lesson equips you with the skills to create reusable, maintainable Python code packaged for easy distribution and testing.
We'll cover the following...
The main difference between a module and a package is that a package is a collection of modules AND it has an __init__.py file. Depending on the complexity of the package, it may have more than one __init__.py. Let’s take a look at a simple folder structure to make this more obvious, then we’ll create some simple code to follow the structure we define.
Now we just need to replicate this structure in our own package. Let’s give that a whirl! Create each of these files in a folder tree like ...