What’s a Python Namespace Package, and What’s It For?
Python namespace packages are an advanced Python feature. You may have heard them mentioned in relation to the __init__.py
file. Specifically, if you don’t include at least an empty __init__.py
file in your package, then your package becomes a namespace package.
For the most part, namespace packages and regular packages won’t behave differently when it comes to using them in your project. In fact, you’ve probably accidentally forgotten to include an __init__.py
file in at least one package but didn’t notice any side effects. While namespace packages are generally a bit slower to import than regular packages, you won’t usually run into many issues.
In this tutorial, you’ll dive into what Python namespace packages are, where they come from,