Now you know what wildcard imports are in Python. You’ve learned that these imports allow you to quickly get all the public objects from modules and packages. To control the process, Python has the __all__ variable, which you can define in your modules and packages as a list of objects that are available for wildcard imports.
The __all__ variable is a list of strings where each string represents the name of a variable, function, class, or module.
In this video course, you’ve learned how to:
- Work with wildcard imports in Python
- Control the modules that you expose to wildcard imports with
__all__ - Control the names that you expose in modules and packages.
- Explore other use cases for the
__all__variable - Understand the benefits and best practices of using
__all__
With this knowledge, you can now write more robust, readable, and reliable modules and packages with explicit behavior against wildcard imports on your code.