Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Managing Imports With Python's __all__ (Summary)

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.

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

00:00 Well done! You completed “Managing Imports With Python’s __all__.” You now know that what may have seemed like a niche variable actually has some really potent uses.

00:10 And today, as more and more code is written with AI assistance, it’s never been more crucial as a developer to understand the nuanced details that ultimately shape your APIs.

00:20 I encourage you to take a look at your past projects and think about where you might apply what you’ve learned. Or maybe start a new project with these concepts in mind.

00:28 In this course, you learned how wildcard imports work in Python, the key differences between wildcard and explicit imports, how __all__ affects imports differently when used in modules versus packages, when and how to effectively use __all__ to customize import behavior, and the common use cases and best practices of using __all__.

00:50 So, where to next? If you want to continue learning about structuring Python applications, follow the “Modules and Packages” learning path. If you’d rather hurry up and use your newfound knowledge to write a package and publish it, check out “Publishing Python Packages to PyPI.” Or for something completely different, and if you just can’t stop thinking about those underscores you kept seeing throughout the course, I recommend “Python’s Magic Methods in Classes,” a deep dive on how dunder methods govern class behavior in Python.

01:19 And that’s it! This has been Art Vandelay, I mean Joseph, and thank you for watching.

Become a Member to join the conversation.